[Python-Dev] __pycode__ extension
Samuele Pedroni
pedronis at bluewin.ch
Thu Nov 18 19:34:51 CET 2004
Phillip J. Eby wrote:
>
>> OTOH I personally fully appreciate why you may want to have it work
>> even if just pycs are around.
>
>
> For me, a half-working __source__ feature is almost worse than none at
> all, since the former could lead to the illusion of making progress
> towards code reflection. This is why I'd like it made clearer what
> problems this is and is not meant to solve, so that programmers who are
> tempted to use the feature will be clearer as to what is and isn't a
> good idea to do with it.
>
well, personally I think an inspect.getsource that is working and
correct as much as possible is a worthy goal. Or a new getast.
At this point I see these possible levels of implementation/functionality:
0) disabled
1) attach source only to exec-ed/eval-ed code
(with this level inspect.getsource would still do the wrong thing
in the case for example of editing)
2) try to always attach source code, don't store it in pyc files,
for correct behavior a likely approach is to read pyc and py files
in parallel
3) always attach source code, store source in some form in the pyc files
I repeat that other means can be devised than flavor 1 of
implementation, to distinguish exec-ed/eval-ed/interactive code from
code from .py files.
Because of people with memory/disk usage considerations and people
preferring no-source shipping we may have to implement to some extent
all of 0,2,3.
Unless e.g. storing ASTs instead of source will be deemed enough safe,
or the fact that in 3 the source is not really just open-text-editor
away (I doubt that).
More information about the Python-Dev
mailing list