Deprecating reload() ???

Skip Montanaro skip at pobox.com
Mon Mar 15 14:50:47 EST 2004


    Dave> The same problem occurs with strings (some strings at least):
    >>> x = 'abcdefghighklmnop'
    >>> y = 'abcdefghighklmnop'
    >>> x is y
    True
    >>> x = 'abc xyz'
    >>> y = 'abc xyz'
    >>> x is y
    False

The difference is the first string has the form of an identifier, so the
interpreter automatically interns it and it gets shared after that.  The
second doesn't.  You can force things though:

    >>> x = 'abc xyz'
    >>> id(x)
    10476320
    >>> x = intern(x)
    >>> x
    'abc xyz'
    >>> id(x)
    10476320
    >>> y = 'abc xyz'
    >>> id(y)
    10477088
    >>> y = intern(y)
    >>> id(y)
    10476320
    >>> x is y
    True

    Dave> We should at least update the description of the reload function
    Dave> in the Python Library Reference.  See the thread "Reload
    Dave> Confusion" for some suggested text.

Please file a bug report on Sourceforge so your ideas don't get lost.  Feel
free to assign it to me (sf id == "montanaro").

Skip




More information about the Python-list mailing list