This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Trundle, benjamin.peterson, daniel.urban, eric.araujo, ncoghlan, pitrou, rhettinger
Date 2011-04-06.13:24:24
SpamBayes Score 1.5974143e-09
Marked as misclassified No
Message-id <>
"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).
Date User Action Args
2011-04-06 13:24:27ncoghlansetrecipients: + ncoghlan, rhettinger, pitrou, benjamin.peterson, eric.araujo, Trundle, daniel.urban
2011-04-06 13:24:27ncoghlansetmessageid: <>
2011-04-06 13:24:25ncoghlanlinkissue10977 messages
2011-04-06 13:24:24ncoghlancreate