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 Mark.Shannon
Recipients Mark.Shannon
Date 2020-06-09.10:13:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591697620.81.0.981270573583.issue40925@roundup.psfhosted.org>
In-reply-to
Content
Currently, there are fourteen macros provided for stack manipulation.
Along with the fundamental, POP(), PUSH() and PEEK(n) the following eleven are also provided:

TOP()          
SECOND()       
THIRD()        
FOURTH()       
SET_TOP(v)     
SET_SECOND(v)  
SET_THIRD(v)   
SET_FOURTH(v)  
SET_VALUE(n, v)
STACK_GROW(n)
STACK_SHRINK(n) 

These are unnecessary as compilers have long understood the sequences of pointer increments and decrements that is generated by using POPs and PUSHes.

See https://godbolt.org/z/Htw-2k which shows GCC generating exactly the same code from just POP, PUSH and PEEK as from direct access to items on the stack.

Removing the redundant macros would make the code easier to reason about and analyze.
TOP() and SECOND() are used quite heavily and are trivial to convert to PEEK by tools, so should probably be left alone.

Notes:

I'm ignoring the stack debugging macros here, they aren't a problem.
The EMPTY() macro is only used twice, so might as well be replaced with STACK_LEVEL == 0.
Sadly, there is no "maintainability/code quality" selection for "type" of issue, so I've chosen "performance" :(
History
Date User Action Args
2020-06-09 10:13:40Mark.Shannonsetrecipients: + Mark.Shannon
2020-06-09 10:13:40Mark.Shannonsetmessageid: <1591697620.81.0.981270573583.issue40925@roundup.psfhosted.org>
2020-06-09 10:13:40Mark.Shannonlinkissue40925 messages
2020-06-09 10:13:40Mark.Shannoncreate