Giter Club home page Giter Club logo

Comments (5)

zhuyifei1999 avatar zhuyifei1999 commented on July 18, 2024

Hmm... my main concern is if people will do numeric operations on these numbers, and it'll be troublesome to copy & paste. Maybe I'll just do the comma separation for repr output and assume that people will know we provide APIs for numeric access if they need it (this needs to be better documented... I'll add to README):

>>> h = guppy.hpy().heap()
>>> h
Partition of a set of 36625 objects. Total size = 4257226 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0  10383  28   917674  22    917674  22 str
     1   9111  25   738760  17   1656434  39 tuple
     2   2384   7   344688   8   2001122  47 types.CodeType
     3   4766  13   336076   8   2337198  55 bytes
     4    441   1   335296   8   2672494  63 type
     5   2205   6   317520   7   2990014  70 function
     6    441   1   247080   6   3237094  76 dict of type
     7     96   0   171952   4   3409046  80 dict of module
     8    240   1   116256   3   3525302  83 dict (no owner)
     9   1090   3    95920   2   3621222  85 types.WrapperDescriptorType
<114 more rows. Type e.g. '_.more' to view.>
>>> len(h)
124
>>> h.count
36625
>>> h.size
4257226
>>> h[0].count
10383
>>> h[0].size
917674

from guppy3.

zhuyifei1999 avatar zhuyifei1999 commented on July 18, 2024
>>> __import__('guppy').hpy().heap()
Partition of a set of 36,633 objects. Total size = 4,257,677 bytes.
 Index   Count   %       Size   %   Cumulative  % Kind (class / dict of class)
     0  10,391  28    917,969  22     917,969  22 str
     1   9,111  25    738,864  17   1,656,833  39 tuple
     2   2,384   7    344,688   8   2,001,521  47 types.CodeType
     3   4,764  13    336,008   8   2,337,529  55 bytes
     4     441   1    335,296   8   2,672,825  63 type
     5   2,205   6    317,520   7   2,990,345  70 function
     6     441   1    247,080   6   3,237,425  76 dict of type
     7      96   0    171,952   4   3,409,377  80 dict of module
     8     240   1    116,256   3   3,525,633  83 dict (no owner)
     9   1,090   3     95,920   2   3,621,553  85 types.WrapperDescriptorType
<114 more rows. Type e.g. '_.more' to view.>
>>> _.byid
Set of 36,633 <mixed> objects. Total size = 4,257,677 bytes.
 Index      Size   %     Cumulative  %   Brief
     0    18,536   0.4      18,536   0.4 dict of module: os
     1     9,328   0.2      27,864   0.7 dict (no owner): 0x7f50d11fb410*323
     2     9,328   0.2      37,192   0.9 dict (no owner): 0x7f50d129beb0*291
     3     9,328   0.2      46,520   1.1 dict of module: posix
     4     8,424   0.2      54,944   1.3 set: 0x7f50d1176050
     5     8,424   0.2      63,368   1.5 set: 0x7f50d11d79b0
     6     8,424   0.2      71,792   1.7 set: 0x7f50d11d7d70
     7     8,424   0.2      80,216   1.9 set: 0x7f50d1254320
     8     8,424   0.2      88,640   2.1 set: 0x7f50d1254c80
     9     7,423   0.2      96,063   2.3 str: 'The class Bi... copy of S.\n'
<36,623 more rows. Type e.g. '_.more' to view.>

Looks decent until

>>> a = list(range(10000000))
>>> __import__('guppy').hpy().heap()
Partition of a set of 10,039,006 objects. Total size = 374,516,749 bytes.
 Index   Count   %       Size   %   Cumulative  % Kind (class / dict of class)
     0 10,000,926 100 280,028,720  75 280,028,720  75 int
     1     100   0 90,019,536  24 370,048,256  99 list
     2  10,989   0    959,949   0 371,008,205  99 str
     3   9,968   0    807,992   0 371,816,197  99 tuple
     4   2,631   0    380,360   0 372,196,557  99 types.CodeType
     5     476   0    372,536   0 372,569,093  99 type
     6   5,236   0    364,636   0 372,933,729 100 bytes
     7   2,382   0    343,008   0 373,276,737 100 function
     8     476   0    262,016   0 373,538,753 100 dict of type
     9      97   0    174,240   0 373,712,993 100 dict of module
<114 more rows. Type e.g. '_.more' to view.>
>>> _.byid
Set of 10,039,006 <mixed> objects. Total size = 374,516,749 bytes.
 Index      Size   %     Cumulative  %   Brief
     0 90,000,120  24.0  90,000,120  24.0 list: 0x7f50d0cb5cd0*10000000
     1    18,536   0.0  90,018,656  24.0 dict of module: os
     2     9,328   0.0  90,027,984  24.0 dict (no owner): 0x7f50d11fb410*323
     3     9,328   0.0  90,037,312  24.0 dict (no owner): 0x7f50d129beb0*291
     4     9,328   0.0  90,046,640  24.0 dict of module: posix
     5     8,424   0.0  90,055,064  24.0 set: 0x7f50d1176050
     6     8,424   0.0  90,063,488  24.0 set: 0x7f50d11d79b0
     7     8,424   0.0  90,071,912  24.1 set: 0x7f50d11d7d70
     8     8,424   0.0  90,080,336  24.1 set: 0x7f50d1254320
     9     8,424   0.0  90,088,760  24.1 set: 0x7f50d1254c80
<10,038,996 more rows. Type e.g. '_.more' to view.>

Goes wild. Maybe I should write some code to align the table.

from guppy3.

cool-RR avatar cool-RR commented on July 18, 2024

I understand.

from guppy3.

svenil avatar svenil commented on July 18, 2024

Good idea and work. Is there an error in the count? Set of 10,039,006 vs 10,038,996 more rows

from guppy3.

zhuyifei1999 avatar zhuyifei1999 commented on July 18, 2024

Good idea and work. Is there an error in the count? Set of 10,039,006 vs 10,038,996 more rows

No ;) 10039006 - 10038996 = 10, 10 rows already displayed :P

from guppy3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.