[pypy-dev] SpaceOperation

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Sep 28 00:25:12 CEST 2011


2011/9/28 Łukasz Ligowski <orangewarrior at gmail.com>

> Hello,
> I'd like to know what is the purpose of offset field on
> pypy.objspace.flow.model.SpaceOperation object.
> It is labeled as "offset in code string" but I have problem to find
> the right string.
> I tried with string that is returned by using string returned by
> FunctionGraph.getsource() but it didn't bring expected results.
> What I try to accomplish is to learn whether it is possible to map
> particular SpaceOperation with right line of original source file.

The "code string" is very likely the bytecode of the Python function,
i.e   f.__code__.co_code.
It's not very easy to get back to the original source line.
f.__code__.co_firstlineno gives the first line number, and other lines
must be computed with the help of f.__code__.co_lnotab.
Good luck with this one. You may want to look at the "dis" module
to see how it is used.

Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20110928/971b9fae/attachment.html>

More information about the pypy-dev mailing list