why does dead code costs time?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Dec 5 12:39:55 EST 2012


On 2012年12月05日 17:34:57 +0000, Steven D'Aprano wrote:
> I believe that's a leftover from
> early Python days when None was not a keyword and could be reassigned.

Oops! Wrong copy and paste! Here's a simpler version:
[steve at ando ~]$ python1.5
Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat 
4.1.2-52)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from dis import dis
>>> def h():
... return None
...
>>> dis(h)
 0 SET_LINENO 1
 3 SET_LINENO 2
 6 LOAD_GLOBAL 0 (None)
 9 RETURN_VALUE
 10 LOAD_CONST 0 (None)
 13 RETURN_VALUE
The conclusion remains the same: calling LOAD_GLOBAL None is likely a 
fossil from ancient Python before it was a keyword.
-- 
Steven


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /