getpelican / pelican-plugins

Collection of plugins for the Pelican static site generator
Other
1.38k stars 849 forks source link

readtime plugin is slow #1118

Open baryluk opened 5 years ago

baryluk commented 5 years ago

My site generation jumps from 18 seconds to 30-40 seconds.

I didn't do profiling, but this is probably due to HTML parser and tag stripping. It isn't great at all.

Few other minor comments about the code:

if x is not None:
  xyz
  abc

can be simplified to:

if not x:
  return
xyz
abc

no need for None, or is, and it deindents code.

Also:

if minuts == 0:
  minutes = 1

simply fold it into minutes expression, as min(1, ...), or as minutes = int(ceil(0.1 + words/WPM)).

Also, lack of unit tests is worrying.

Lucas-C commented 5 years ago

Do you plan on submitting a PR about this ?