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
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com