This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author penguin_wwy
Recipients Dennis Sweeney, corona10, penguin_wwy
Date 2022-03-20.15:04:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1647788665.61.0.571474932949.issue47067@roundup.psfhosted.org>
In-reply-to
Content
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)
```
History
Date User Action Args
2022-03-20 15:04:25penguin_wwysetrecipients: + penguin_wwy, corona10, Dennis Sweeney
2022-03-20 15:04:25penguin_wwysetmessageid: <1647788665.61.0.571474932949.issue47067@roundup.psfhosted.org>
2022-03-20 15:04:25penguin_wwylinkissue47067 messages
2022-03-20 15:04:25penguin_wwycreate