[Python-Dev] PySet API

Aahz aahz at pythoncraft.com
Sun Mar 26 18:07:28 CEST 2006

On Sun, Mar 26, 2006, Raymond Hettinger wrote:
> [Alex]
>>  And I'm on the fence regarding the specific issue  of PySet_Next.
>> So, having carefully staked out a position smack in the middle, I
>> cheerfully now expect to be fired upon from both sides!-)
> Okay, here's the first cheap shot ;-) Which of the following pieces of
> code is preferable?  The first loops with the iterator protocol and
> the second loops with the _next protocol.

Speaking as a person who does relatively little C programming, I don't
see much difference between them.  The first example is more Pythonic --
for Python.  I agree with Barry that it's not much of a virtue for C

However, I do have one nitpick with both your examples; I don't know
whether this is an artifact of them being examples:

>                 hash ^= h * 3644798167;

Seems to me that magic numbers like this need to be made constants and
explained with a comment.
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Look, it's your affair if you want to play with five people, but don't
go calling it doubles."  --John Cleese anticipates Usenet

More information about the Python-Dev mailing list