Message397879
I found that replacing __call__ on the NewType class with an identity function written in C makes things faster instead:
In [54]: %timeit ntc2(1)
79 ns ± 0.37 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
In [55]: %timeit ntc(1)
126 ns ± 0.315 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
In [56]: %timeit nt(1)
103 ns ± 4.23 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
Here ntc2 has __call__ implemented in C, ntc is the previous class-based version and nt is the current function-based version.
So perhaps we could just stick a private `._idfunc` in some C-implemented module (functools? types?) and use it as the __call__ for our NewType class. |
|
Date |
User |
Action |
Args |
2021-07-20 15:09:02 | JelleZijlstra | set | recipients:
+ JelleZijlstra, gvanrossum, lukasz.langa, levkivskyi, miss-islington, uriyyo, joperez, domdfcoding, kj |
2021-07-20 15:09:02 | JelleZijlstra | set | messageid: <1626793742.57.0.0770832303809.issue44353@roundup.psfhosted.org> |
2021-07-20 15:09:02 | JelleZijlstra | link | issue44353 messages |
2021-07-20 15:09:02 | JelleZijlstra | create | |
|