byroot / pysrt

Python parser for SubRip (srt) files
GNU General Public License v3.0
451 stars 69 forks source link

Faster loading #79

Open pisuke opened 5 years ago

pisuke commented 5 years ago

Hi, thanks for this very useful library! More than an issue, this is a question: is there a way to speed up loading of .SRT files? I have a use case where I use SRT files to encode lighting events and the files end up being between 50MB and 100MB (they could be much more too). I would like to check any ideas you might have before moving to a binary format or to start thinking about loading files in chunks. Thanks! Francesco

byroot commented 5 years ago

I never actually profiled the library, so if you were to do it, you might find a few optimizable hotspots.

Other than that, I can't really think of any huge wins. However if you are parsing huge files, and you don't need it all in memory at once, you'd be better to use the stream API: https://github.com/byroot/pysrt/blob/e23ca39de37d54e988f4726c311aee4d4770c2ca/pysrt/srtfile.py#L185

pisuke commented 5 years ago

Thanks for the quick reply! The stream API looks exactly like what I need, I'll give it a go. :-)