Hi Enrico, Officially, I think what you want to do isn't really supported by python.
does not correspond to a valid __file__ you can open and inspect.
In practice you can probably manage it if make a few assumptions.
You can access these attributes (or their C values directly): myfunc.__code__.co_filename myfunc.__code__.co_firstlineno
Personally I'd not worry about the PyCodeObject changing (though without more details on what you do its hard to say).
Or you could import the 'inspect' module via the C api and call its getsource() function, however 'inspect' just makes a guess too and isn't guaranteed to give the correct result, this at least gets around changes in PyCodeObject but assumes a full python installation.