On-topic: alternate Python implementations

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Aug 4 22:19:26 EDT 2012


On Sat, 04 Aug 2012 18:38:33 -0700, Paul Rubin wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info> writes:
>> Runtime optimizations that target the common case, but fall back to
>> unoptimized code in the rare cases that the optimization doesn't apply,
>> offer the opportunity of big speedups for most code at the cost of
>> trivial slowdowns when you do something unusual.
> 
> The problem is you can't always tell if the unusual case is being
> exercised without an expensive dynamic check, which in some cases must
> be repeated in every iteration of a critical inner loop, even though it
> turns out that the program never actually uses the unusual case.

I never said optimizing Python was easy :)

Obviously if the check is expensive enough, the optimization isn't going 
to be worth doing. But often the check is not so expensive, or is just a 
matter of tedious and careful book-keeping.

I don't wish to dispute that optimizing Python is hard, but it's not a 
Hard Problem like factorizing huge integers, or solving the Palestine/
Israeli conflict. It's hard like cleaning your house after a gang of 
drunken frat boys have partied all weekend.



-- 
Steven



More information about the Python-list mailing list