Skip to content

Commit

Permalink
Assignment expression code optimization x 1.
Browse files Browse the repository at this point in the history
This commit is the first in a commit chain significantly optimizing
generation of **assignment expressions** (i.e., PEP 572-compliant Python
expressions containing the ":=" walrus operator) throughout code
snippets dynamically generated by @beartype's type-checking code
generator. Since strings are expensive to repeatedly generate, @beartype
now internally caches and reuses frequently used local variables across
assignment expressions. In truth, this means nothing. But @leycec just
*had* to do this to satisfy his aberrant OCD disorder. I swear! It isn't
my fault! It's fast or it ain't @beartype. (*Tsundera or tundra!?*)
  • Loading branch information
leycec committed Mar 8, 2024
1 parent 1f419dc commit c32ed7d
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 325 deletions.
4 changes: 2 additions & 2 deletions beartype/_check/checkmagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@
'''

# ....................{ NAMES ~ var : pith }....................
VAR_NAME_PREFIX_PITH = f'{NAME_PREFIX}pith_'
VAR_NAME_PITH_PREFIX = f'{NAME_PREFIX}pith_'
'''
Substring prefixing all local variables providing a **pith** (i.e., either the
current parameter or return value *or* item contained in the current parameter
or return value being type-checked by the current call).
'''


VAR_NAME_PITH_ROOT = f'{VAR_NAME_PREFIX_PITH}0'
VAR_NAME_PITH_ROOT = f'{VAR_NAME_PITH_PREFIX}0'
'''
Name of the local variable providing the **root pith** (i.e., value of the
current parameter or return value being type-checked by the current call).
Expand Down

0 comments on commit c32ed7d

Please sign in to comment.