Author uriyyo
Recipients Mark.Shannon, corona10, jstasiak, methane, serhiy.storchaka, uriyyo
Date 2020-11-17.18:51:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605639070.93.0.439066952204.issue42202@roundup.psfhosted.org>
In-reply-to
Content
I have run tests with different types of function declaration.


A function declaration with annotations is more than 2 times faster with the co_annotatins feature.

If function doesn't have annotations time almost same as without co_annotatins feature.

Results:
```
def foo(x: int, /, y, *, z: float) -> int: pass

Python 3.8.3
5000000 loops, best of 5: 178 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 210 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 122 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 53.3 nsec per loop

def f(a: int, /, b: int, *, c: int) -> None: pass

Python 3.8.3
5000000 loops, best of 5: 208 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 235 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 139 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 53.2 nsec per loop

def f(a: int, /, b: int, *, c: int, **d: int) -> None: pass

Python 3.8.3
5000000 loops, best of 5: 224 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 257 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 167 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 55.9 nsec per loop

def f(a: int, b: str) -> None: pass

Python 3.6.8
5000000 loops, best of 3: 0.163 usec per loop
Python 3.7.6
5000000 loops, best of 5: 165 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 165 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 184 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 125 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 54.5 nsec per loop

def f(a: int, *, b: int) -> None: pass

Python 3.6.8
5000000 loops, best of 3: 0.166 usec per loop
Python 3.7.6
5000000 loops, best of 5: 170 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 155 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 198 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 124 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 54.3 nsec per loop

def f(a, /, b, *, c) -> None: pass

Python 3.8.3
5000000 loops, best of 5: 90.1 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 96.3 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 93.8 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 55.5 nsec per loop

def f(a, /, b, *, c, **d) -> None: pass

Python 3.8.3
5000000 loops, best of 5: 92.3 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 98 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 92.6 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 54.4 nsec per loop

def f(a, b) -> None: pass

Python 3.6.8
5000000 loops, best of 3: 0.0966 usec per loop
Python 3.7.6
5000000 loops, best of 5: 92.5 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 87.5 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 93.7 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 88.3 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 53 nsec per loop

def f(a, *, b) -> None: pass

Python 3.6.8
5000000 loops, best of 3: 0.0951 usec per loop
Python 3.7.6
5000000 loops, best of 5: 92.4 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 86.6 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 93.6 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 89.8 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 53.6 nsec per loop

def f(): pass

Python 3.6.8
5000000 loops, best of 3: 0.0502 usec per loop
Python 3.7.6
5000000 loops, best of 5: 47.7 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 47.9 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 46.7 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 50.8 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 52 nsec per loop

def f(a, /, b, *, c): pass

Python 3.8.3
5000000 loops, best of 5: 47.9 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 47.4 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 50.2 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 52.8 nsec per loop

def f(a, /, b, *, c, **d): pass

Python 3.8.3
5000000 loops, best of 5: 48.7 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 48.2 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 50.8 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 52.4 nsec per loop

def f(a, b): pass

Python 3.6.8
5000000 loops, best of 3: 0.0498 usec per loop
Python 3.7.6
5000000 loops, best of 5: 48.5 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 47.5 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 47 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 51 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 52.6 nsec per loop

def f(a, *, b): pass

Python 3.6.8
5000000 loops, best of 3: 0.0498 usec per loop
Python 3.7.6
5000000 loops, best of 5: 48.1 nsec per loop
Python 3.8.3
5000000 loops, best of 5: 48.4 nsec per loop
Python 3.9.0
5000000 loops, best of 5: 46.6 nsec per loop
Python 3.10.0a2+
5000000 loops, best of 5: 50.2 nsec per loop
Python 3.10.0a2+ with co_annotations
5000000 loops, best of 5: 52.6 nsec per loop
```
History
Date User Action Args
2020-11-17 18:51:10uriyyosetrecipients: + uriyyo, methane, Mark.Shannon, serhiy.storchaka, jstasiak, corona10
2020-11-17 18:51:10uriyyosetmessageid: <1605639070.93.0.439066952204.issue42202@roundup.psfhosted.org>
2020-11-17 18:51:10uriyyolinkissue42202 messages
2020-11-17 18:51:10uriyyocreate