[Python-Dev] Making None a keyword

Jeremy Hylton jeremy@ZOPE.COM
Fri, 26 Apr 2002 10:10:12 -0400

>>>>> "FLD" == Fred L Drake, <fdrake@acm.org> 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:

		case LOAD_CONST:
			x = GETCONST(oparg);
			goto fast_next_opcode;

we'd have this:

		case LOAD_NONE:
			goto fast_next_opcode;

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.