Python Improvement Idea: Singleton protection

Greg Ewing see at my.signature
Thu Aug 17 23:41:59 EDT 2000


Warren Postma wrote:
> 
> So, with all that code in there, I was def-reffing Py_None twice in my code.
> 
> It seemeth to me that there ought to be a better way to track these things.

You might find it less confusing for yourself if you
design your own functions such as HandleResult to
follow the standard Python refcounting conventions,
i.e. take borrowed references rather than "stealing"
them.

> couldn't a global flag called "PySingletonProtection" be set to
> 1, and if the destructor of the Nothing Type is invoked, it would raise an
> exception there,

That would catch one particular form of refcounting error,
but there are plenty of others. I'm not sure whether it's
worth doing anything special about that one case.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list