[Python-Dev] PySet API

Alex Martelli aleaxit at gmail.com
Sun Mar 26 08:57:32 CEST 2006

On Mar 25, 2006, at 9:57 PM, Aahz wrote:

> I'd really like to see someone else who understands the issues (i.e.
> using the Python C-API) weigh in.  Both Barry and Raymond are clever
> programmers who generally understand what's Pythonic, and I find  
> myself
> agreeing with whoever posted last.  ;-)  Having another perspective
> would probably shed some light here.

My general preference is rather well-known, and I quote the advice I  
gave in "Python in a Nutshell"...:
Some of the functions callable on specifically-typed objects [...]  
duplicate functionality that is also available from PyObject_  
functions; in these cases, you should almost invariably use the more  
general PyObject_ function instead. I don’t cover such almost- 
redundant functions in this book.

However, I don't go as far as suggesting PyObject_CallMethod and the  
like... I'd much rather have abstract-layer PyObject_... functions,  
as long as they're applicable to two or more concrete built-in types  
(for example, IMHO adding PyObject_Clear is a no-brainer -- it's  
obviously right).  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!-)


More information about the Python-Dev mailing list