penguin_wwy <940375...@qq.com> added the comment:

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)
```

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue47067>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to