Traversing the object space.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lothar Scholz

    Traversing the object space.

    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.
  • Jp Calderone

    #2
    Re: Traversing the object space.

    On Mon, Sep 01, 2003 at 11:31:45AM -0700, Lothar Scholz wrote:[color=blue]
    > 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.[/color]


    import gc
    print gc.get_objects( )

    Jp
    [color=blue]
    > --
    > http://mail.python.org/mailman/listinfo/python-list[/color]

    --
    "Pascal is Pascal is Pascal is dog meat."
    -- M. Devine and P. Larson, Computer Science 340

    Comment

    • Mark Hahn

      #3
      Re: Traversing the object space.

      > > Ruby has a nice function that can traverse the complete object space[color=blue][color=green]
      > > 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.[/color]
      >
      >
      > import gc
      > print gc.get_objects( )
      >[/color]

      Does this only report objects that support the garbage collector?


      Comment

      • Michael Hudson

        #4
        Re: Traversing the object space.

        llothar@web.de (Lothar Scholz) writes:
        [color=blue]
        > Ruby has a nice function that can traverse the complete object space
        > of your program.
        >
        > Is there anything like this in python ?[/color]

        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

        Comment

        Working...