News for hackers. Stuff that matters.
Re:Making Python Programs Blazingly Fast by eesmith on Wednesday January 01, 2020 @03:56PM (#21930569)
Should also use kernprof - https://github.com/rkern/line_profiler - to see which lines in that function take the most time.

Oddly, none of the techniques listed would help that slow_program.py function since kernprof says that 99.8% of the time is spent in:

    s += num / fact
One comment about "# Fast:" / "from re import findall" -- That's not fast. Sure, it reduces a getattr lookup, but it's much better to pre-compile the regex than to pass it in to re.findall() each time.

Now, re.findall() does cache the last 100 or so regexps, so it probably won't re-evaluate the regex each time. But really, pre-compute that regex with "_my_pattern = re.compile(regex) ... _my_pattern.findall()" and avoid even that cache lookup.

Re:Making Python Programs Blazingly Fast by Bostonian on Wednesday January 01, 2020 @03:36PM (#21930440)
"Python haters always say, that one of the reasons they don’t want to use it, is that it’s slow."

There are no critics nowadays, only "haters". This word usage irks me. Someone who does not use Python because he thinks it is too slow does not "hate" it.

Re:Making Python Programs Blazingly Fast by MartinHeinz on Wednesday January 01, 2020 @03:39PM (#21930460)
Fair enough, I guess that's bad wording. Critic is better word here.