Ray.Allen <ysj....@gmail.com> added the comment:

krisvale:

> What about my suggestion of simply providing a convention on how to disable 
> links manually, similar to how minidom.document does it with an "unlink" 
> method?  If these cases are documented, then there shouldn't be any extra 
> bother to do so.
We could provide an builtin unlink() function that calls any __unlink__ special 
method if present.


Maybe through this way such problems can be solved, but it seems it's not 
graceful and pythonic enough. The reason such an "unlink" method appears in 
xml.dom.minidom is because usually large xml document can eat up so much memory 
that we had to do something to make the memory garbaged sooner. But adding this 
as a standard __unlink__ method and requiring explicitly call the unlink() 
method make it similar as using c & c++, which require explicitly memory 
release. 

Besides, as you mentioned, "exposes an implementation detail of C python", it's 
better that the object reference mechanism be fully controlled by python core 
and not be awared by users at all. That is also one of the purposes of 
designing python. 

I prefer terry's idea, which suggests adding a metaclass that produces rc-free 
class to stdlib. These class should behave almost the same as the ones "type" 
metaclass produces. In order not to introduce the slower lookup, we can also 
add a little differences on usage of such classes, for example, internally 
store mro list without the class itself, but construct a full mro list when 
getting the __mro__ attribute, and different "super" implementation, since 
explicitly getting the mro is not so common in practice.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9417>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to