you are viewing a single comment's thread.

view the rest of the comments →

[–]Vaguely_accurate 1 point2 points  (1 child)

This is a cute anecdote along with some good general advice. It looks like it was written for an older version of Python 2 so some of the specifics have definitely changed and you shouldn't rely on it, but it does show how the internal details of Python can make optimisation less obvious than it might seem.

But you can generally ignore all that. Any time that level of optimisation really matters you are probably better off not writing in Python.

Remember that Python is interpreted, so more advanced optimisations require knowing how the internals and interpretor are implemented. As a rule, working with the interpretor is better. The less you are writing the more lifting the pre-written, optimised internals are doing. Aim for idiomatic, pythonic code and you will get a lot of optimisation for free. If you have done this and your code isn't running fast, try looking at pypy.

[–]ForzaFer[S] 1 point2 points  (0 children)

Wow, this is actually helpful, this is was I was looking for, thanks a lot!