PEP 572: Add a short section on performance

This commit is contained in:
Chris Angelico 2018-02-28 16:35:51 +11:00
parent abf11d2954
commit b2d428ce48
1 changed files with 17 additions and 0 deletions

View File

@ -84,6 +84,23 @@ avoided where regular assignment can be used, just as ``lambda`` should be
avoided when ``def`` is an option.
Performance costs
=================
The cost of SLNBs must be kept to a minimum, particularly when they are not
used; the normal case MUST NOT be measurably penalized. SLNBs are expected
to be uncommon, and using many of them in a single function should definitely
be discouraged. Thus the current implementation uses a linked list of SLNB
cells, with the absence of such a list being the normal case. This list is
used for code compilation only; once a function's bytecode has been baked in,
execution of that bytecode has no performance cost compared to regular
assignment.
Other Python implementations may choose to do things differently, but a zero
run-time cost is strongly recommended, as is a minimal compile-time cost in
the case where no SLNBs are used.
Open questions
==============