[MERGE] Use slots consistently in InventoryEntry hierarchy -- regenerated against new head. Seeking another reviewer.
John A Meinel
john at arbash-meinel.com
Wed May 31 14:01:36 BST 2006
Jan Hudec wrote:
> On Tue, May 30, 2006 at 19:23:44 -0400, Aaron Bentley wrote:
...
>
> These two are a good idea. Thanks.
>
> I want to do the properties stuff. I originally wanted to convert the
> base attributes to slots (with the patch I sent) and add a proplist
> dictionary with the other ones (executable + properties defined by
> plugins (eg. newline-style, keyword expansion, charset conversion, unix
> permissions etc.). Now that would add a dictionary back, right? And
> quite many operations would have to look at it anyway. So this leads me
> to thinking that perhaps I should unify the core and non-core attributes
> and use methods like you suggested for everything, not just the
> proplist.
>
We should do some memory and speed benchmarking before we give a final
determination as to whether we use __slots__ or not.
Does anyone know a good way to do memory debugging with Python? I know
in the past I've seen that Python doesn't give you a good handle on
memory consumption. I know you can get an idea of # of instantiated
objects by iterating some of the gc stuff. I think the only memory
benchmarking I've seen involved reading a /proc file (something like
/proc/<PID>/status)
The /proc stuff seems very platform dependent, though if it works on
some machines, it might be worthwhile.
This did seem to work in my limited testing:
>>> def get_status():
... f = open('/proc/%s/status' % (os.getpid(),), 'rb')
... res = {}
... for line in f.readlines():
... key, value = line.split(':', 1)
... res[key] = value.strip()
... return res
>>> get_status()['VmSize']
'6036 kB'
>>> y = ' '*1000000
>>> get_status()['VmSize']
'7096 kB'
>>> y = ' '*10000000
>>> get_status()['VmSize']
'15884 kB'
>>> del y
>>> get_status()['VmSize']
'6116 kB'
There is also 'VmPeak', which I think would be useful.
It seems to work on both Ubuntu and Fedora Core, though Mac OSX doesn't
have a /proc to inspect.
The nicest thing, of course, would be if you could inspect gc and get
the size of each object, rather than just the count of references to it.
Is there something exposed in the C api that we could use?
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060531/ac477b8b/attachment.pgp
More information about the bazaar
mailing list