Repository navigation
Commit 9de76f2
authored
Add `@vectorcall` to `function.__new__`. There is no change of exception text for bad arguments.
Benchmark:
```
+-------------------------------+--------+----------------------+
| Benchmark | main | patch |
+===============================+========+======================+
| FunctionType(code, gns) | 196 ns | 150 ns: 1.31x faster |
+-------------------------------+--------+----------------------+
| types.FunctionType(code, gns) | 193 ns | 153 ns: 1.26x faster |
+-------------------------------+--------+----------------------+
| Geometric mean | (ref) | 1.28x faster |
+-------------------------------+--------+----------------------+
```
```python
import pyperf
SETUP = """
import sys
import types
from types import FunctionType
def f(self):
pass
class C:
def m(self):
pass
obj = C()
code = f.__code__
gns = globals()
d = {}
frame = sys._getframe()
"""
CASES = [
("FunctionType(code, gns)", "FunctionType(code, gns)"),
("types.FunctionType(code, gns)", "types.FunctionType(code, gns)"),
]
runner = pyperf.Runner()
for name, stmt in CASES:
runner.timeit(name, stmt=stmt, setup=SETUP)
```
1 parent 39af026 commit 9de76f2
2 files changed
Lines changed: 72 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1096 | 1096 | | |
1097 | 1097 | | |
1098 | 1098 | | |
| 1099 | + | |
1099 | 1100 | | |
1100 | 1101 | | |
1101 | 1102 | | |
| |||
1118 | 1119 | | |
1119 | 1120 | | |
1120 | 1121 | | |
1121 | | - | |
| 1122 | + | |
1122 | 1123 | | |
1123 | 1124 | | |
1124 | 1125 | | |
| |||
1326 | 1327 | | |
1327 | 1328 | | |
1328 | 1329 | | |
| 1330 | + | |
1329 | 1331 | | |
1330 | 1332 | | |
1331 | 1333 | | |
| |||
0 commit comments