Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] PEP 205 comments

Martin v. Loewismartin@loewis.home.cs.tu-berlin.de
Fri, 12 Jan 2001 23:19:57 +0100


Before commenting on the patch itself, I'd like to comment on thepatch describing it.I'm missing a discussion as to why weak references don't act asproxies (or why they do now). A weak proxy would provide the sameattributes as the object which it encapsulates, so it could be usedtransparently in place of the original object. I can think of a numberof reasons why it is not done this way (e.g. complete transparency isimpossible to achieve); now that a revision of the patch providesproxies, the documentation should state which features are forwardedto the proxy and which aren't (it lists the type() as a difference,but I doubt that is the only difference - repr is also different).Next, I wonder whether weakref.new is allowed to return an existingweak reference to the same object. If that is not acceptable, I'd liketo know why - if it was acceptable, then weakref.new(instance)(i.e. without callback) could return the same weak reference all thetime. A smart implementation might chose to put the weak referencewith no callback in the start of the list, so creation of additionalweak references to the same object would be inexpensive.Likewise, I'd like to know the rationale for the clear method. Why isit desirable to drop the object, yet keep the weak reference? Isn't iteasier for the application to either ignore clearing altogether, ordropping the reference to the weak reference? So I'd propose to killthe clear method.Again on proxies, there is no discussion or documentation of theReferenceError. Why is it a RuntimeError? LookupError, ValueError, andAttributeError seem to be just as fine or better.On to the type type extensions: Should there be a type flag indicatingpresence of tp_weaklistoffset? It appears that the type structure hadtp_xxx7 for a long time, so likely all in-use binary modules havethat field set to zero. Is that sufficient?Thanks for reading all of this message,Martin


[8]ページ先頭

©2009-2025 Movatter.jp