Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1401442
  • 博文数量: 343
  • 博客积分: 13098
  • 博客等级: 上将
  • 技术积分: 2862
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-06 00:35
文章存档

2012年(131)

2011年(31)

2010年(53)

2009年(23)

2008年(62)

2007年(2)

2006年(36)

2005年(5)

分类: Python/Ruby

2010-12-06 00:18:44

Getting started with Heapy

Usage example

The following example shows

  1. How to create the session context: hp=hpy()
  2. How to use the interactive help: hp.doc, hp.doc.doc
  3. How to show the reachable objects in the heap: hp.heap()
  4. How to create and show a set of objects: hp.iso(1,[],{})
  5. How to show the shortest paths from the root to x: hp.iso(x).sp
>>> from guppy import hpy; hp=hpy()
>>> hp
Top level interface to Heapy.
Use eg: hp.doc for more info on hp.
>>> hp.doc
Top level interface to Heapy. Available attributes:
Anything            Nothing             Via                 iso
Class               Rcs                 doc                 load
Clodo               Root                findex              monitor
Id                  Size                heap                pb
Idset               Type                heapu               setref
Module              Unity               idset               test
Use eg: hp.doc. for info on .
>>> hp.doc.doc
Overview documentation for top level Heapy object.
Provides a listing of the available attributes.
Accessing the attribute name on the doc objects gives further info, eg:

    >>> hp.doc.heap

gives doc for the heap method when hp is the top level Heapy object.

References may be embedded in the documentations. To access a
reference, opening up a web browser with the doc for it one can do eg:

    >>> hp.doc.heap[1]

The reference number 0 is special. If it is provided, it is the
reference to the html doc for the described object itself. So to see
in the web browser the doc for the heap method one can do:

    >>> hp.doc.heap[0]

References
    [0] heapy_Use.html#heapykinds.Use.doc
>>> hp.heap()
Partition of a set of 48477 objects. Total size = 3265516 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0  25773  53  1612820  49   1612820  49 str
     1  11699  24   483960  15   2096780  64 tuple
     2    174   0   241584   7   2338364  72 dict of module
     3   3478   7   222592   7   2560956  78 types.CodeType
     4   3296   7   184576   6   2745532  84 function
     5    401   1   175112   5   2920644  89 dict of class
     6    108   0    81888   3   3002532  92 dict (no owner)
     7    114   0    79632   2   3082164  94 dict of type
     8    117   0    51336   2   3133500  96 type
     9    667   1    24012   1   3157512  97 __builtin__.wrapper_descriptor
<76 more rows. Type e.g. '_.more' to view.>
>>> hp.iso(1,[],{})
Partition of a set of 3 objects. Total size = 176 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0      1  33      136  77       136  77 dict (no owner)
     1      1  33       28  16       164  93 list
     2      1  33       12   7       176 100 int
>>> x=[]
>>> hp.iso(x).sp
 0: hp.Root.i0_modules['__main__'].__dict__['x']
>>> 
阅读(1121) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~