Thank you for your input, choroba. I've run each of the programs on input generated by your command and it seems that the Perl version does indeed best the Python one. My original input was an expanded form of the Day 3, Advent of Code 2024 input.
So I modified your snippet to run 10000000 iterations, which resulted in a 99MiB file for me. This is similar in size to the original input I used. In doing that, I found that the Perl version again runs slower: 0.626s, to Python's 0.416s.
Can you replicate this? It indicates to me that perhaps Python's regex implementation scales better.
-- edit: Or perhaps Python's interpreter has a larger startup cost and its regex implementation is indeed faster in this case...
In reply to Re^2: Python regex faster than Perl?
by dave93
in thread Python regex faster than Perl?
by dave93
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |