python 3.3 repr
Cousin Stanley
cousinstanley at gmail.com
Fri Nov 15 12:45:54 EST 2013
> ....
> We don't say len({42: None}) to discover
> that the dict requires 136 bytes,
> why would you use len("heåvy")
> to learn that it uses 23 bytes ?
> ....
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
illustrate the difference in length of python objects
and the size of their system storage
"""
import sys
s = "heåvy"
d = { 42 : None }
print
print ' s : %s' % s
print ' len( s ) : %d' % len( s )
print ' sys.getsizeof( s ) : %s ' % sys.getsizeof( s )
print
print
print ' d : ' , d
print ' len( d ) : %d' % len( d )
print ' sys.getsizeof( d ) : %d ' % sys.getsizeof( d )
--
Stanley C. Kitching
Human Being
Phoenix, Arizona
More information about the Python-list
mailing list