[Python-Dev] PEP 267 -- is the semantics change OK?

Jim Jewett jimjjewett at gmail.com
Sat Oct 22 00:25:47 CEST 2005

(In http://mail.python.org/pipermail/python-dev/2005-October/057501.html)
Neil Schemenauer suggested PEP 267 as an example of something that
might be easier with the AST compiler.

As written, PEP 267 does propose a slight semantics change -- but it
might be an improvement, if it is acceptable.

Today, after

    from othermod import val1
    import othermod
    val2 = othermod.val2
    othermod.val3  # Just making sure it was referenced early

    othermod.val1 = "new1"
    othermod.val2 = "new2"
    othermod.val3 = "new3"

    print val1, val2, othermod.val3

The print statement will see the updated val3, but will still have
the original values for val1 and val2.

Under PEP267, all three variables would be compiled to a slot
access in othermod, and would see the updated objects.

In many cases, this would be a *good* thing.  It might allow
reload to be rewritten to do what people expect.  On the other
hand, it would be a change.  Would it be an acceptable change?


More information about the Python-Dev mailing list