May-26-2023, 05:49 AM
Hi! I'm new to Python source code reading, but I'm curious and I want to chase the following example's execution on CPython source level
I'm wondering if something happens on __next__ and __iter__ and __hash__ methods on set, but take a glance at CPython source code taught me they are implemented in C. I'm not familiar with the source code connections between C and Python codes on CPython repository
How can I follow this? Also, is this behavior of the set-iterator of integer noted on some doc? Thanks in advance!
x = set([1]) for i in x: y = x.pop()+1 x.add(y) print(x)above code always print
{8}
on my M2 Mac.I'm wondering if something happens on __next__ and __iter__ and __hash__ methods on set, but take a glance at CPython source code taught me they are implemented in C. I'm not familiar with the source code connections between C and Python codes on CPython repository
How can I follow this? Also, is this behavior of the set-iterator of integer noted on some doc? Thanks in advance!