Message415613
The point of bpo-40369 issue seems to be to provide vectorcall to the `GenericAliasType`, means vectorcall for `Queue[int]`
However, my idea is to add vectorcall to gaobject, like this:
```
d = dict[int]
d(a=1, b=2) <-- vectorcall
```
The idea came from my desire to implement different subclasses of a type when implementing some kind of factory model:
```
class ChildClassBuilder:
...
def set_type(self, t: Type):
self.t = t
def build():
instance = self.t()
...
return instance
```
In the case of high type-hint coverage, the `self.t` is often a gaobject.
Benchmark example:
```
def test():
d = dict[int]
for _ in range(1000000):
d(a=1, b=2)
```
Speedup 20% in my wsl2
```
opt:
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 1.728 1.728 <string>:1(<module>)
1 1.728 1.728 1.728 1.728 test.py:4(test)
master:
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 2.271 2.271 <string>:1(<module>)
1 2.271 2.271 2.271 2.271 test.py:4(test)
``` |
|
Date |
User |
Action |
Args |
2022-03-20 15:04:25 | penguin_wwy | set | recipients:
+ penguin_wwy, corona10, Dennis Sweeney |
2022-03-20 15:04:25 | penguin_wwy | set | messageid: <1647788665.61.0.571474932949.issue47067@roundup.psfhosted.org> |
2022-03-20 15:04:25 | penguin_wwy | link | issue47067 messages |
2022-03-20 15:04:25 | penguin_wwy | create | |
|