Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on A Python Optimization Anecdote.
Some best practices when optimizing CPython code:
* Re-evaluate your algorithm (an inefficient quicksort is still faster than an optimized bubblesort)
* Use Python functions and constructs implemented in C (ex. most builtins, list comprehensions)
* Move loops from outside functions to inside (function call overhead is high)
* Use try/except to handle uncommon cases rather than using conditional checks in a loop.
* Eliminate dots (attribute lookup) in tight loops (create a local alias if needed)
See also: http://wiki.python.org/moin/PythonSpeed/PerformanceTips
There are no comments on this comment yet.
Some best practices when optimizing CPython code:
* Re-evaluate your algorithm (an inefficient quicksort is still faster than an optimized bubblesort)
* Use Python functions and constructs implemented in C (ex. most builtins, list comprehensions)
* Move loops from outside functions to inside (function call overhead is high)
* Use try/except to handle uncommon cases rather than using conditional checks in a loop.
* Eliminate dots (attribute lookup) in tight loops (create a local alias if needed)
See also: http://wiki.python.org/moin/PythonSpeed/PerformanceTips