On Tue, Mar 7, 2017 at 4:36 PM, Erik <pyt...@lucidity.plus.com> wrote:
> * listextend() - this should do the right thing with the type hint when >> extending one list with another. >> > > * Several other methods ('contains', 'remove', 'count', 'index') also use > PyObject_RichCompareBool(). They could also presumably benefit from the > same optimisation (perhaps it's not all about sort() - perhaps this gives a > little more weight to the idea). Good point about list.extend(). I don't think __type_hint__ could help with .__contains__() or .count() or .remove(). E.g.: In [7]: lst = [1.0, 2.0, 1+0j, F(1,1)] In [8]: from fractions import Fraction as F In [9]: lst = [1.0, 2.0, 1+0j, F(1,1)] In [10]: 1 in lst Out[10]: True In [11]: lst.count(1) Out[11]: 3 In [12]: l.index(1) Out[12]: 0 The list has absolutely nothing of the right type. Yet it contains an item, counts things that are equal, finds a position for an equal item. -- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/