sum() vs. loop

Avi Gross avigross at
Wed Oct 13 14:23:10 EDT 2021

Yes, Stefan, I realized that and did not test more thoroughly. Chris pointed
it out too. I indeed deleted the names but a second reference remained so I
may be wrong and the function may just keep track of the position and return
one tuple at a time. That would be a good design, unless there was a worry
the original might be changed out from under. 

My apologies if it was understood to mean I had shown it was copied.

-----Original Message-----
From: Python-list < at> On
Behalf Of Stefan Ram
Sent: Tuesday, October 12, 2021 9:49 PM
To: python-list at
Subject: Re: sum() vs. loop

"Avi Gross" <avigross at> writes:
>I did a test where I made two list called A and B and used zip to make 
>an object holding the two and then removed A and B. I was able to print 
>the list of tuples just fine with print(list(C)) so clearly it is not 
>so much a pure iterator as one that holds yet another copy of both lists!

  You may have "deleted the names", but not the lists.

a =[ 10, 11, 12 ]
b =[ 20, 21, 22 ]
c = zip( a, b )
del a[ 0 ], a[ 0 ], a[ 0 ]
del b[ 0 ], b[ 0 ], b[ 0 ]
print( a, b, list( c ))


[] [] []



More information about the Python-list mailing list