pysrt icon indicating copy to clipboard operation
pysrt copied to clipboard

Faster loading

Open pisuke opened this issue 5 years ago • 2 comments

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

pisuke avatar Aug 04 '19 14:08 pisuke

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

byroot avatar Aug 04 '19 14:08 byroot

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

pisuke avatar Aug 04 '19 14:08 pisuke