Creating a List of Empty Lists

Emile van Sebille emile at
Sat Dec 6 23:19:20 CET 2003

Skip Montanaro:
>  [ quoting me ]
>     Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit
(Intel)] on win32
>     >>> b = intern('foo bar')
>     >>> a = 'foo bar'
>     >>> a is 'foo bar'
>     False
>     >>> b is 'foo bar'
>     False
>     Emile> That apparent space requirement should really be better
> The fact that the current implementation of CPython automatically
> strings which look like identifiers is simply an efficiency
> It's not part of the language definition, so doesn't bear
documenting.  The
> correct way to compare two strings is using '==' (which is
independent of
> CPython's implementation details), not 'is'.
> Skip

OK.  But does intern() intern?  I (thought I) only used is to show
that it wasn't intern()'d, and as the documentation holds intern'ing
up as an optimization technique, does it _only_ apply to strings that
look like identifiers?  How else might you know?

Emile van Sebille
emile at

More information about the Python-list mailing list