[Python-Dev] PEP: __source__ proposal
holger krekel
hpk at trillke.net
Sat Dec 4 09:59:38 CET 2004
[Stelios Xanthakis Fri, Dec 03, 2004 at 11:59:30PM +0200]
> On Fri, 3 Dec 2004, holger krekel wrote:
> >We are about to test out this approach with the py lib
> >(http://codespeak.net/py) and want to have it work for
> >for Python 2.2, 2.3. and 2.4.
>
> Do you plan hacking python ?
> It appears that tok_nextc() is the best place to
> catch all the source passed to the interpreter.
Well, as we want to have the library work on past python
versions modifying CPython 2.5 does not make much sense.
It's more about (like Martin pointed out) organizing
dynamic code generation so that Python's introspect
and traceback logic works as much as possible - with
tiny runtime "monkey" patches if needed.
Now Martin also correctly pointed out that you can store
source code before/after you pass it to compile/parse.
We are doing this already with an external dictionary.
This has multithreading issues, though. So we think that
hooking onto code's objects co_filename or a module's __file__
might be an interesting idea.
cheers,
holger
More information about the Python-Dev
mailing list