Nick Coghlan <ncogh...@gmail.com> added the comment:

"should" is a wonderful word when it comes to external APIs.

We currently have a couple of problems:

1. The concrete APIs will fail noisily if given an instance of something that 
isn't a list, but may fail *silently* if given a subclass that adds additional 
state that needs to be kept in sync.

2. We don't have a standard "fast path with fallback" idiom for containers, so 
any code that wants to support arbitrary sequences has to either accept the 
performance penalty, or code the fast path at every point it gets used.

Changing the concrete APIs to be more defensive and fall back to the abstract 
APIs if their assumptions are violated would be a win on both of those fronts.

I also retract my performance concern from above - all of the affected code 
paths already include a "Py<X>_Check()" that triggers PyErr_BadInternalCall() 
if it fails. All we would be doing is moving that check further down in the 
function and dealing with a negative result differently.

Some code paths would become slightly slower when used with subclasses of 
builtin types, but a lot of currently broken code would automatically start 
supporting subclasses of builtins correctly (and be well on its way to being 
duck-typed, instead of only working with the builtin types).

----------

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

Reply via email to