Traversing the object space.

Discussion in 'Python' started by Lothar Scholz, Sep 1, 2003.

  1. Ruby has a nice function that can traverse the complete object space
    of your program.

    Is there anything like this in python ? It seems to be not in the
    standart library but maybe i can find a short script somewhere else.

    It is a nice way for to do some memory checks to find out if a part of
    your app is generating too much objects.
     
    Lothar Scholz, Sep 1, 2003
    #1
    1. Advertising

  2. Lothar Scholz

    Jp Calderone Guest

    On Mon, Sep 01, 2003 at 11:31:45AM -0700, Lothar Scholz wrote:
    > Ruby has a nice function that can traverse the complete object space
    > of your program.
    >
    > Is there anything like this in python ? It seems to be not in the
    > standart library but maybe i can find a short script somewhere else.
    >
    > It is a nice way for to do some memory checks to find out if a part of
    > your app is generating too much objects.



    import gc
    print gc.get_objects()

    Jp

    > --
    > http://mail.python.org/mailman/listinfo/python-list


    --
    "Pascal is Pascal is Pascal is dog meat."
    -- M. Devine and P. Larson, Computer Science 340
     
    Jp Calderone, Sep 1, 2003
    #2
    1. Advertising

  3. Lothar Scholz

    Mark Hahn Guest

    > > Ruby has a nice function that can traverse the complete object space
    > > of your program.
    > >
    > > Is there anything like this in python ? It seems to be not in the
    > > standart library but maybe i can find a short script somewhere else.
    > >
    > > It is a nice way for to do some memory checks to find out if a part of
    > > your app is generating too much objects.

    >
    >
    > import gc
    > print gc.get_objects()
    >


    Does this only report objects that support the garbage collector?
     
    Mark Hahn, Sep 1, 2003
    #3
  4. (Lothar Scholz) writes:

    > Ruby has a nice function that can traverse the complete object space
    > of your program.
    >
    > Is there anything like this in python ?


    In a debug build, there's sys.getobjects(). In recent release builds,
    there's gc.get_objects() which I think only returns containers, but a
    bit of creativity can find all objects from there (note that, unless
    you try really hard instances of any classes you define will count as
    containers).

    Cheers,
    mwh

    --
    ARTHUR: Why should he want to know where his towel is?
    FORD: Everybody should know where his towel is.
    ARTHUR: I think your head's come undone.
    -- The Hitch-Hikers Guide to the Galaxy, Episode 7
     
    Michael Hudson, Sep 2, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick Cuckson

    traversing LDAP name space

    Nick Cuckson, Jan 6, 2004, in forum: Java
    Replies:
    0
    Views:
    507
    Nick Cuckson
    Jan 6, 2004
  2. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,938
    Bryan Bullard
    Jul 11, 2003
  3. Christian Seberino
    Replies:
    21
    Views:
    1,721
    Stephen Horne
    Oct 27, 2003
  4. Ian Bicking
    Replies:
    2
    Views:
    1,056
    Steve Lamb
    Oct 23, 2003
  5. Ian Bicking
    Replies:
    2
    Views:
    752
    Michael Hudson
    Oct 24, 2003
Loading...

Share This Page