Bug: dictionary with >= 8192 keys not initialized correctly
rwgk at my-deja.com
rwgk at my-deja.com
Wed Aug 9 14:42:48 EDT 2000
Save this to a file dictbug.py:
print 'd1 = {'
for i in xrange(8191):
print str(i) + ': None,'
print '}'
print 'd2 = {'
for i in xrange(8192):
print str(i) + ': None,'
print '}'
print 'print len(d1)'
print 'print len(d2)'
Then run:
python dictbug.py > tmp.py
python tmp.py
The output is:
8191
0
I tested this with:
Python 1.5.2 (#1, Apr 28 2000, 11:50:55) [C] on osf1V5
Python 1.6b1 (#1, Aug 4 2000, 22:34:57) [C] on osf1V5
Python 1.5.2 (#1, Sep 17 1999, 20:15:36) [GCC egcs-2.91.66
19990314/Linux (egcs- on linux-i386
If a dictionary is generated dynamically, e.g. by adding keys
in a loop, there is no problem if there are >= 8192 keys.
If there is an inherent problem with large dictionaries, it would
be good if Python could at least raise an exception, e.g. SystemError.
Ralf
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list