Commit 5a78607
Another two micro-optimizations (#19633)
Here are two things:
* Make `FormalArgument` a native class. We create huge amount of these
(as callable subtyping is one of the most common subtype checks), and
named tuples creation is significantly slower than native classes.
* Do not call `re.match()` in a code path of `format_type()`. This is
relatively slow (as it is a `py_call()`) and it is called in almost
every error message. This creates problems for code with many
third-party dependencies where these errors are ignored anyway.
FWIW in total these give ~0.5% together (I didn't measure individually,
but I guess the most benefit for self-check is from the first one).
---------
Co-authored-by: Ali Hamdan <[email protected]>1 parent 6d0ce5e commit 5a78607
3 files changed
+24
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2432 | 2432 | | |
2433 | 2433 | | |
2434 | 2434 | | |
2435 | | - | |
| 2435 | + | |
2436 | 2436 | | |
2437 | 2437 | | |
2438 | 2438 | | |
2439 | 2439 | | |
2440 | 2440 | | |
2441 | | - | |
| 2441 | + | |
2442 | 2442 | | |
2443 | 2443 | | |
2444 | 2444 | | |
| |||
2517 | 2517 | | |
2518 | 2518 | | |
2519 | 2519 | | |
2520 | | - | |
2521 | 2520 | | |
2522 | 2521 | | |
2523 | 2522 | | |
2524 | | - | |
2525 | 2523 | | |
2526 | 2524 | | |
2527 | | - | |
2528 | | - | |
| 2525 | + | |
2529 | 2526 | | |
2530 | 2527 | | |
2531 | 2528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 8 | + | |
20 | 9 | | |
21 | 10 | | |
22 | 11 | | |
| |||
1607 | 1596 | | |
1608 | 1597 | | |
1609 | 1598 | | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
1615 | 1618 | | |
1616 | 1619 | | |
1617 | 1620 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1612 | 1612 | | |
1613 | 1613 | | |
1614 | 1614 | | |
1615 | | - | |
| 1615 | + | |
1616 | 1616 | | |
1617 | 1617 | | |
1618 | 1618 | | |
| |||
0 commit comments