From 22b2265053ef9fec4b1aedab770b32f71b0c85f7 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 7 Jan 2016 14:40:35 +0000 Subject: py/parse: Improve constant folding to operate on small and big ints. Constant folding in the parser can now operate on big ints, whatever their representation. This is now possible because the parser can create parse nodes holding arbitrary objects. For the case of small ints the folding is still efficient in RAM because the folded small int is stored inplace in the parse node. Adds 48 bytes to code size on Thumb2 architecture. Helps reduce heap usage because more constants can be computed at compile time, leading to a smaller parse tree, and most importantly means that the constants don't have to be computed at runtime (perhaps more than once). Parser will now be a little slower when folding due to calls to runtime to do the arithmetic. --- tests/misc/non_compliant.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/misc/non_compliant.py b/tests/misc/non_compliant.py index 0cf462abb..9c55ac2c3 100644 --- a/tests/misc/non_compliant.py +++ b/tests/misc/non_compliant.py @@ -70,20 +70,22 @@ try: except NotImplementedError: print('NotImplementedError') +mpz = 1 << 70 + # mpz and with both args negative try: - -(1<<70) & -2 + -mpz & -2 except NotImplementedError: print('NotImplementedError') # mpz or with args opposite sign try: - -(1<<70) | 2 + -mpz | 2 except NotImplementedError: print('NotImplementedError') # mpz xor with args opposite sign try: - -(1<<70) ^ 2 + -mpz ^ 2 except NotImplementedError: print('NotImplementedError') -- cgit v1.2.3