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 vstinner
Recipients vstinner
Date 2017-03-06.14:56:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488812174.68.0.707747009021.issue29736@psf.upfronthosting.co.za>
In-reply-to
Content
Attached PR replaces PyArg_ParseTupleAndKeywords() with
_PyArg_ParseTupleAndKeywordsFast() to optimize the constructor of the
builtin types:

* bool: bool_new()
* bytes: bytes_new()
* complex: complex_new()
* float: float_new()
* int: long_new()
* list: list_init()
* str: unicode_new()
* tuple: tuple_new()

When using keywords, the speedup is between 1.55x faster and 1.92x faster.

When using only positional arguments, the speedup is between 1.07x faster and 1.14x faster.

Results of attached bench.py:

+-----------------------------------------------+--------+---------------------+
| Benchmark                                     | ref    | changed             |
+===============================================+========+=====================+
| complex(real=0.0, imag=0.0)                   | 452 ns | 1.92x faster (-48%) |
+-----------------------------------------------+--------+---------------------+
| bytes("x", encoding="ascii", errors="strict") | 498 ns | 1.88x faster (-47%) |
+-----------------------------------------------+--------+---------------------+
| str(b"x", encoding="ascii")                   | 340 ns | 1.55x faster (-35%) |
+-----------------------------------------------+--------+---------------------+
| list([None])                                  | 208 ns | 1.14x faster (-12%) |
+-----------------------------------------------+--------+---------------------+
| int(0)                                        | 113 ns | 1.11x faster (-10%) |
+-----------------------------------------------+--------+---------------------+
| float(1.0)                                    | 110 ns | 1.10x faster (-9%)  |
+-----------------------------------------------+--------+---------------------+
| str("x")                                      | 115 ns | 1.10x faster (-9%)  |
+-----------------------------------------------+--------+---------------------+
| tuple((None,))                                | 111 ns | 1.10x faster (-9%)  |
+-----------------------------------------------+--------+---------------------+
| bytes(b"x")                                   | 126 ns | 1.10x faster (-9%)  |
+-----------------------------------------------+--------+---------------------+
| bool(True)                                    | 107 ns | 1.09x faster (-8%)  |
+-----------------------------------------------+--------+---------------------+
| complex(0.0, 0.0)                             | 176 ns | 1.07x faster (-7%)  |
+-----------------------------------------------+--------+---------------------+
History
Date User Action Args
2017-03-06 14:56:14vstinnersetrecipients: + vstinner
2017-03-06 14:56:14vstinnersetmessageid: <1488812174.68.0.707747009021.issue29736@psf.upfronthosting.co.za>
2017-03-06 14:56:14vstinnerlinkissue29736 messages
2017-03-06 14:56:14vstinnercreate