I noticed that the string slicing (copying) was really slowing things down, particularly when parsing a larger file (such as hpcalc.org's 2022 snapshot torrent).
This change tracks an index in the string instead of slicing it. This improves performance by 20-70x for me on the big torrent file.
I tried to retain your code's simple elegance while speeding things up.
Hi Utku,
Thank you for this library.
I noticed that the string slicing (copying) was really slowing things down, particularly when parsing a larger file (such as hpcalc.org's 2022 snapshot torrent).
This change tracks an index in the string instead of slicing it. This improves performance by 20-70x for me on the big torrent file.
I tried to retain your code's simple elegance while speeding things up.
Tested on Python 2.7 and 3.9.