summaryrefslogtreecommitdiffstatshomepage
path: root/docs/esp8266/tutorial
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-10-06 13:44:54 +1100
committerDamien George <damien@micropython.org>2024-07-01 13:52:59 +1000
commit557d31ed2c75e90b2f2c534c7019cb51aab5a7c8 (patch)
tree1a76c8cbbc1863a167d4f52bfbe73cc34f487191 /docs/esp8266/tutorial
parent0600e4f27333092884358c967123dcc040d7a1cc (diff)
downloadmicropython-557d31ed2c75e90b2f2c534c7019cb51aab5a7c8.tar.gz
micropython-557d31ed2c75e90b2f2c534c7019cb51aab5a7c8.zip
py/objint: Try to convert big-int back to small-int after binary op.
Before this change, long/mpz ints propagated into all future calculations, even if their value could fit in a small-int object. With this change, the result of a big-int binary op will now be converted to a small-int object if the value fits in a small-int. For example, a relatively common operation like `x = a * b // c` where a,b,c all small ints would always result in a long/mpz int, even if it didn't need to, and then this would impact all future calculations with x. This adds +24 bytes on PYBV11 but avoids heap allocations and potential surprises (e.g. `big-big` is now a small `0`, and can safely be accessed with MP_OBJ_SMALL_INT_VALUE). Performance tests are unchanged on PYBV10, except for `bm_pidigits.py` which makes heavy use of big-ints and gains about 8% in speed. Unix coverage tests have been updated to cover mpz code that is now unreachable by normal Python code (removing the unreachable code would lead to some surprising gaps in the internal C functions and the functionality may be needed in the future, so it is kept because it has minimal overhead). This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'docs/esp8266/tutorial')
0 files changed, 0 insertions, 0 deletions