[Python-Dev] PySet_Next (Was: PySet API)

Barry Warsaw barry at python.org
Mon Mar 27 16:32:26 CEST 2006


On Sun, 2006-03-26 at 21:50 +0200, "Martin v. Löwis" wrote:

> I don't know what specific application Barry has in mind, but I'm
> sure he can get it right (although it might be an interesting experiment
> to test that theory :-) In general, I would expect that people find
> it easier to get code involving PyDict_Next right than code dealing
> with iterators - primarily because of the error cases you have to
> consider.

I can't post the code because it's proprietary, but I gave a general
feel to the types of things we do in a previous response.  Imagine you
have application objects that are also PyObjects.  They have application
specific state and behavior.  They can be put in Python sets and they
can be iterated over to check that state, invoke that behavior (which
won't involve trips into Python), or perhaps add them to other
collections.  Do this 50 to 60 times in your application and I think
you'll start to see why the iterator protocol is incredibly cumbersome
to use.

> I don't care that much either way, although I would prefer to see an
> actual, current use case for PySet_Next, rather than theoretical,
> made-up examples. I don't expect to use Python sets in C code at all,
> personally.

We really, honestly do use PySet_Next in many places.  We implemented
that API for Python 2.4 exactly because the iterator protocol was way
too much overhead.  The posted patch is a port to Python 2.5.  We
obviously can't add this to Python 2.4, but I had really hoped that we
wouldn't have to maintain this extension for subsequent versions.  I'm
frankly astonished to get so much pushback from Raymond about it.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20060327/f4d4ba37/attachment.pgp 


More information about the Python-Dev mailing list