Message133126
"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:27 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, pitrou, benjamin.peterson, eric.araujo, Trundle, daniel.urban |
2011-04-06 13:24:27 | ncoghlan | set | messageid: <1302096267.53.0.491295632503.issue10977@psf.upfronthosting.co.za> |
2011-04-06 13:24:25 | ncoghlan | link | issue10977 messages |
2011-04-06 13:24:24 | ncoghlan | create | |
|