[New-bugs-announce] [issue44775] Speed-up typing.cast by implementing it in C

Yurii Karabas report at bugs.python.org
Fri Jul 30 05:28:49 EDT 2021


New submission from Yurii Karabas <1998uriyyo at gmail.com>:

In scope of https://github.com/python/cpython/pull/27262 we have introduce `_typing` module with typing related helper functions.

It will be great to speedup `typing.cast` function by implementing it in C.

I have already done it and here is results:
```
import timeit
import typing
import _typing

def _timeit(m):
    print(m.__name__, timeit.timeit("cast(int, 1)", globals={"cast": m.cast}))

_timeit(typing)
_timeit(_typing)
```

```
typing  0.0702372890082188
_typing 0.033294505992671475
```

----------
components: Library (Lib)
messages: 398529
nosy: kj, uriyyo
priority: normal
severity: normal
status: open
title: Speed-up typing.cast by implementing it in C
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44775>
_______________________________________


More information about the New-bugs-announce mailing list