# Just by looking at the output, it seems pretty obvious that xrange
would be more memory effcient for large ranges:
print "With range():",range(100,200)
print
print "With xrange():",xrange(100,200)
d = {1:2,2:3,3:4}
d.items()
d.iteritems()
# I have been curious to use Pysizer (which requires patching Python)
to demonstrate the difference.
Drew wrote:
When is it appropriate to use dict.items() vs dict.iteritems. Both
seem to work for something like:
for key,val in mydict.items():
print key,val
for key,val in mydict.iteritems():
print key,val
Also, when is it appropriate to use range() vs xrange(). From my
understanding, xrange() essentially gives you an iterator across a
range, so it should be used when iterating. Should you only use
range() when want to physically store the range as a list?
Thanks,
Drew
--
Shane Geiger
IT Director
National Council on Economic Education
[EMAIL PROTECTED] | 402-438-8958 | http://www.ncee.net
Leading the Campaign for Economic and Financial Literacy
begin:vcard
fn:Shane Geiger
n:Geiger;Shane
org:National Council on Economic Education (NCEE)
adr:Suite 215;;201 N. 8th Street;Lincoln;NE;68508;United States
email;internet:[EMAIL PROTECTED]
title:IT Director
tel;work:402-438-8958
x-mozilla-html:FALSE
url:http://www.ncee.net
version:2.1
end:vcard
--
http://mail.python.org/mailman/listinfo/python-list