At 12:41 PM 1/11/05 +0000, Armin Rigo wrote:
The point about tp_xxx slots is that when implemented in C with slots, you get
the latter (correct) effect for free.  This is how metaconfusion is avoided in
post-2.2 Python.  Using getattr() for that is essentially broken.  Trying to
call the method and catching TypeErrors seems pretty fragile -- e.g. if you
are calling a __conform__() which is implemented in C you won't get a Python
frame in the traceback either.

An excellent point. The issue hasn't come up before now, though, because there aren't any __conform__ methods written in C in the field that I know of. Presumably, if there are any added to CPython in future, it will be because there's a tp_conform slot and it's needed for built-in types, in which case the problem is again moot for the implementation.


(FYI, C methods implemented in Pyrex add a dummy frame to the traceback such that you see the file and line number of the original Pyrex source code. Very handy for debugging.)

Anyway, I agree that your version of the code should be used to form the reference implementation, since the purpose of the reference implementation is to show the complete required semantics.

_______________________________________________
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

Reply via email to