11.07.2015 Views

versión color - PET: Python Entre Todos - Python Argentina

versión color - PET: Python Entre Todos - Python Argentina

versión color - PET: Python Entre Todos - Python Argentina

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Enter Guppy 85>>> from guppy import hpy>>> hp = hpy()>>> hp.heap()Partition of a set of 23778 objects. Total size = 1760692 bytes.Index Count % Size % Cumulative % Kind (class / dict of class)0 10642 45 696652 40 696652 40 str1 5432 23 196864 11 893516 51 tuple2 345 1 112968 6 1006484 57 dict (no owner)3 1546 7 105128 6 1111612 63 types.CodeType4 66 0 104592 6 1216204 69 dict of module5 174 1 93168 5 1309372 74 dict of type6 194 1 86040 5 1395412 79 type7 1472 6 82432 5 1477844 84 function8 124 1 67552 4 1545396 88 dict of class9 1027 4 36972 2 1582368 90 __builtin__.wrapper_descriptorO sea, <strong>Python</strong> (por el simple hecho de levantarlo) ya consume 1.7MB. En objetospython. Heapy no cuenta lo que no son objetos <strong>Python</strong>, así que lo que reporte heapyes todo memoria utilizada directamente por objetos <strong>Python</strong>.Esto son cadenas, listas, diccionarios, arrays, pero no objetos mmap o memoriautilizada por bibliotecas de extensión (ej: superficies SDL en pygame).Diagnostiquemos ahora entonces:>>> l = []>>> for i in xrange(1,100):... …>>> hp.heap()Partition of a set of 2612542 objects. Total size = 866405844 bytes.Index Count % Size % Cumulative % Kind (class / dict of class)0 2599386 99 854833304 99 854833304 99 str1 132 0 10516640 1 865349944 100 list2 5433 0 197064 0 865547008 100 tuple3 351 0 113784 0 865660792 100 dict (no owner)4 1547 0 105196 0 865765988 100 types.CodeType5 67 0 105112 0 865871100 100 dict of module6 174 0 93168 0 865964268 100 dict of type7 194 0 86040 0 866050308 100 type{footer} — http://revista.python.org.ar

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!