[Python-ideas] Re: `not not x` much faster than `bool(x)`

2021-08-06 Thread Serhiy Storchaka
06.08.21 10:29, wyz2...@163.com пише: > Before the introduction of bool and also in other languages, `not not x` > was/is used to convert to True (1) and False (0). However, the old way is > still much faster than bool(x) or even operator.truth(x). > Test: >> py -3.10 -m timeit -s "objects = 1,

[Python-ideas] Re: `not not x` much faster than `bool(x)`

2021-08-06 Thread Steven D'Aprano
On Fri, Aug 06, 2021 at 08:29:03AM -, wyz2...@163.com wrote: > I thought that many places in stdlib could be made faster by this > (bool is used a lot), maybe this is a major speedup. I doubt that there are many places in the stdlib where the call to bool is the bottleneck, and a

[Python-ideas] Re: `not not x` much faster than `bool(x)`

2021-08-06 Thread Thomas Grainger
how does it compare with the old: ``` def rh(ham, _bool=bool): return _bool(ham) ``` ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: `not not x` much faster than `bool(x)`

2021-08-06 Thread wyz23x2
I thought that many places in stdlib could be made faster by this (bool is used a lot), maybe this is a major speedup. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org

[Python-ideas] Re: `not not x` much faster than `bool(x)`

2021-08-06 Thread Chris Angelico
On Fri, Aug 6, 2021 at 5:31 PM wrote: > > Before the introduction of bool and also in other languages, `not not x` > was/is used to convert to True (1) and False (0). However, the old way is > still much faster than bool(x) or even operator.truth(x). > Test: > > py -3.10 -m timeit -s "objects =