[Python-Dev] Making None a keyword
Fri, 26 Apr 2002 10:10:12 -0400
>>>>> "FLD" == Fred L Drake, <email@example.com> writes:
FLD> Jeremy Hylton writes:
>> Does the parser prevent assignment to None? Or does the compiler
>> need to check for the use of None in an assignment?
FLD> Inside functions, you don't even need that. You just need to
FLD> use LOAD_CONST (or whatever its called now), since None is
FLD> entry 0 in the constants table, used by the implied "return
FLD> None" when control drops off the end. Doing this in function
FLD> buys most of the performance.
I don't understand what you mean, but I'll try to reply anyway :-).
I assume LOAD_NONE will eliminate the need for LOAD_CONST 0 (None).
Instead of this:
x = GETCONST(oparg);
we'd have this:
It's probably a wee bit faster and it makes the bytecode smaller,
because you don't need None in co_consts and you don't need an
argument to the bytecode.
Based on my cycle counter measurements before the conference, I
suspect the performance impact is, well, negligible.