[Python-Dev] Accessing value stack (original) (raw)
Maciej Fijalkowski fijall at gmail.com
Mon Jan 7 21:43:06 CET 2013
- Previous message: [Python-Dev] Accessing value stack
- Next message: [Python-Dev] FYI: don't CC the peps mailing list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Jan 7, 2013 at 10:40 PM, PJ Eby <pje at telecommunity.com> wrote:
On Mon, Jan 7, 2013 at 11:32 AM, Brett Cannon <brett at python.org> wrote:
On Mon, Jan 7, 2013 at 10:46 AM, Maciej Fijalkowski <fijall at gmail.com> wrote:
On Mon, Jan 7, 2013 at 4:22 PM, Oleg Broytman <phd at phdru.name> wrote:
On Mon, Jan 07, 2013 at 03:06:51PM +0100, Dima Tisnek <dimaqq at gmail.com> wrote:
Hi, is it possible to access the values stored on the stack in Python stack machine from Python?
In short: it's possible but very much discouraged. Don't hack into python internals. Is it possible? I claim it's not (from Python because obviously data is in memory). Nope, it's not. I took that as a challenge, and just tried to do it using gc.getreferents(). ;-) Didn't work though... which actually makes me wonder if that's a bug in gc.getreferents(), or whether I'm making a bad assumption about when you'd have to run gc.getreferents() on a frame in order to see items from the value stack included. Could this actually be a bug in frames' GC implementation, or are value stack items not supposed to count for GC purposes?
valustack is a static list in C (it's not a Python list at all) that's stored on the frame. You can't do it that way. gc.get_referrers returns you only python objects (and in fact should return you only python objects that are accessible otherwise, but those details are really implementation-dependent)
- Previous message: [Python-Dev] Accessing value stack
- Next message: [Python-Dev] FYI: don't CC the peps mailing list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]