New-style classes, iter and PySequence_Check

Raymond Hettinger vze4rx4y at verizon.net
Thu Apr 14 23:59:34 EDT 2005


[Bengt Richter]
> I'm not sure, but I think it may be expedient optimization practicality
beating purity.

It is more a matter of coping with the limitations of the legacy API where want
to wrap a sequence iterator around __getitem__  in sequences but not in
mappings.



> <snipped code experiments>
> I haven't walked the relevant iter() code.
> That would be too easy ;-)

The actual code for Object/abstract.c's PyObject_GetIter() is somewhat more
straight-forward and less mysterious than those experiments suggest.



Raymond





More information about the Python-list mailing list