From b2d428ce485df60b25cce464f319d113c884e0ce Mon Sep 17 00:00:00 2001 From: Chris Angelico Date: Wed, 28 Feb 2018 16:35:51 +1100 Subject: [PATCH] PEP 572: Add a short section on performance --- pep-0572.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pep-0572.rst b/pep-0572.rst index 8b6b83c5a..ee8e0b64f 100644 --- a/pep-0572.rst +++ b/pep-0572.rst @@ -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 ==============