@@ -1298,32 +1298,32 @@ Bucher, with additional help from Irit Katriel and Dennis Sweeney.)
1298
1298
| Operation | Form | Specialization | Operation speedup | Contributor(s) |
1299
1299
| | | | (up to) | |
1300
1300
+===============+====================+=======================================================+===================+===================+
1301
- | Binary | ``x+x; x*x; x-x; `` | Binary add, multiply and subtract for common types | 10% | Mark Shannon, |
1302
- | operations | | such as `` int ``, `` float ``, and `` str `` take custom | | Dong-hee Na, |
1303
- | | | fast paths for their underlying types. | | Brandt Bucher, |
1301
+ | Binary | ``x + x `` | Binary add, multiply and subtract for common types | 10% | Mark Shannon, |
1302
+ | operations | | such as :class: ` int `, :class: ` float ` and :class: ` str ` | | Dong-hee Na, |
1303
+ | | `` x - x `` | take custom fast paths for their underlying types. | | Brandt Bucher, |
1304
1304
| | | | | Dennis Sweeney |
1305
+ | | ``x * x `` | | | |
1305
1306
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1306
- | Subscript | ``a[i] `` | Subscripting container types such as `` list ``, | 10-25% | Irit Katriel, |
1307
- | | | `` tuple `` and `` dict `` directly index the underlying | | Mark Shannon |
1308
- | | | data structures. | | |
1307
+ | Subscript | ``a[i] `` | Subscripting container types such as :class: ` list `, | 10-25% | Irit Katriel, |
1308
+ | | | :class: ` tuple ` and :class: ` dict ` directly index | | Mark Shannon |
1309
+ | | | the underlying data structures. | | |
1309
1310
| | | | | |
1310
- | | | Subscripting custom `` __getitem__ `` | | |
1311
+ | | | Subscripting custom :meth: ` ~object. __getitem__ ` | | |
1311
1312
| | | is also inlined similar to :ref: `inline-calls `. | | |
1312
1313
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1313
1314
| Store | ``a[i] = z `` | Similar to subscripting specialization above. | 10-25% | Dennis Sweeney |
1314
1315
| subscript | | | | |
1315
1316
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1316
1317
| Calls | ``f(arg) `` | Calls to common builtin (C) functions and types such | 20% | Mark Shannon, |
1317
- | | ``C(arg) `` | as ``len `` and ``str `` directly call their underlying | | Ken Jin |
1318
- | | | C version. This avoids going through the internal | | |
1319
- | | | calling convention. | | |
1320
- | | | | | |
1318
+ | | | as :func: `len ` and :class: `str ` directly call their | | Ken Jin |
1319
+ | | ``C(arg) `` | underlying C version. This avoids going through the | | |
1320
+ | | | internal calling convention. | | |
1321
1321
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1322
- | Load | ``print `` | The object's index in the globals/builtins namespace | [1 ]_ | Mark Shannon |
1323
- | global | `` len `` | is cached. Loading globals and builtins require | | |
1324
- | variable | | zero namespace lookups. | | |
1322
+ | Load | ``print() `` | The object's index in the globals/builtins namespace | [#load-global ]_ | Mark Shannon |
1323
+ | global | | is cached. Loading globals and builtins require | | |
1324
+ | variable | `` len() `` | zero namespace lookups. | | |
1325
1325
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1326
- | Load | ``o.attr `` | Similar to loading global variables. The attribute's | [2 ]_ | Mark Shannon |
1326
+ | Load | ``o.attr `` | Similar to loading global variables. The attribute's | [#load-attr ]_ | Mark Shannon |
1327
1327
| attribute | | index inside the class/object's namespace is cached. | | |
1328
1328
| | | In most cases, attribute loading will require zero | | |
1329
1329
| | | namespace lookups. | | |
@@ -1335,14 +1335,15 @@ Bucher, with additional help from Irit Katriel and Dennis Sweeney.)
1335
1335
| Store | ``o.attr = z `` | Similar to load attribute optimization. | 2% | Mark Shannon |
1336
1336
| attribute | | | in pyperformance | |
1337
1337
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1338
- | Unpack | ``*seq `` | Specialized for common containers such as ``list `` | 8% | Brandt Bucher |
1339
- | Sequence | | and ``tuple ``. Avoids internal calling convention. | | |
1338
+ | Unpack | ``*seq `` | Specialized for common containers such as | 8% | Brandt Bucher |
1339
+ | Sequence | | :class: `list ` and :class: `tuple `. | | |
1340
+ | | | Avoids internal calling convention. | | |
1340
1341
+---------------+--------------------+-------------------------------------------------------+-------------------+-------------------+
1341
1342
1342
- .. [1 ] A similar optimization already existed since Python 3.8. 3.11
1343
- specializes for more forms and reduces some overhead.
1343
+ .. [#load-global ] A similar optimization already existed since Python 3.8.
1344
+ 3.11 specializes for more forms and reduces some overhead.
1344
1345
1345
- .. [2 ] A similar optimization already existed since Python 3.10.
1346
+ .. [#load-attr ] A similar optimization already existed since Python 3.10.
1346
1347
3.11 specializes for more forms. Furthermore, all attribute loads should
1347
1348
be sped up by :issue: `45947 `.
1348
1349
0 commit comments