[Python-Dev] Proposal: explicitly disallow function/class mismatches in accelerator modules

Emanuel Barry vgr255 at live.ca
Mon Jul 11 09:42:00 EDT 2016


> From: Steven D'Aprano
> Sent: Monday, July 11, 2016 9:11 AM
> This isn't an actual problem that occurred in real code, it's a
> theoretical issue that Emanuel discovered, and by his own admission
> feels that he was doing something dubious ("It may not be the best idea
> to subclass something that is meant to be final" -- ya think?). Raymond
> Hettinger makes some good points about the costs of feature creep needed
> to support these accidental implementation features, and is against it.

Yes, this hasn't actually happened; hypothetic bugs make for the best
discussions though ;)

> But on the other hand, Serhiy also makes some good points about the
> usefulness of pickling partial objects. So as far as this *specific*
> issue goes, perhaps it is justified to make sure the Python
> implementation supports pickling.
> But generalising this to all possibly mismatches between a C class
> implementation and a Python function implementation doesn't necessarily
> follow. Raymond's general point about simplicity versus feature creep
> still stands, even if in this case adding pickling is useful.

I'm not sure about feature creep in this particular case; pickling for
instance is no accident, even if it's not documented. Is there a particular
stance on non-accidental, undocumented features (if that makes any sense)?

> [1] If I'm wrong about this, and these features are supported, then
> Emanuel has found a hole in the functools test suite and a weakness in
> our testing: it's too hard to ensure that *both* the Python and C code
> is tested.

As far as tests go, there's a large common set of tests for either version
(which is the entirety of the Python version's tests), and the C version
extends those with the tests for repr(), pickling and copying, and does all
the tests again for a subclass. This probably doesn't mean much as far as
guaranteed API is concerned, but it does mean that it's (at least
internally) supported.


More information about the Python-Dev mailing list