This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nnorwitz
Recipients arigo, nnorwitz
Date 2008-02-27.16:32:10
SpamBayes Score 0.00021659442
Marked as misclassified No
Message-id <ee2a432c0802270832k2416f629t8a3a4b505ea1e0d@mail.gmail.com>
In-reply-to <1204129285.06.0.343181381985.issue2181@psf.upfronthosting.co.za>
Content
>  I suppose you are aware that performing this optimization in general
>  would break a lot of existing code that uses inspect.getstack() or
>  sys._getframe() to peek at the caller's local variables.  I know this

Yes, with this optimization the variable might never be set or when
the function exits, the value would be set to the previous value.

Note that the current optimization only works just before a return and
only for local variables.  It doesn't generally optimize out
variables, although that would be a good next step.

>  because it's one thing that Psyco doesn't do correctly, and one of the
>  most common causes I'm aware of for a random existing program to break
>  under Psyco.

How often does this cause problems?  Do you view this as psyco's
problem or broken user code?

I don't view this any different that a C compiler optimizing out
variables.  It can make debugging harder since the symbols no longer
exist.  In this case the variable name is not removed from the
co_varnames even if it is the only reference.  That would also be
nice, but left for another patch.  Since this will only be used with
-O and is currently limited, this seems reasonable to me.  But I would
like to know if others disagree.
History
Date User Action Args
2008-02-27 16:32:13nnorwitzsetspambayes_score: 0.000216594 -> 0.00021659442
recipients: + nnorwitz, arigo
2008-02-27 16:32:11nnorwitzlinkissue2181 messages
2008-02-27 16:32:10nnorwitzcreate