micropython/py
Dan Ellis 6f4d424f46 py/formatfloat: Use pow(10, e) instead of pos/neg_pow lookup tables.
Rework the conversion of floats to decimal strings so it aligns precisely
with the conversion of strings to floats in parsenum.c.  This is to avoid
rendering 1eX as 9.99999eX-1 etc.  This is achieved by removing the power-
of-10 tables and using pow() to compute the exponent directly, and that's
done efficiently by first estimating the power-of-10 exponent from the
power-of-2 exponent in the floating-point representation.

Code size is reduced by roughly 100 to 200 bytes by this commit.

Signed-off-by: Dan Ellis <dan.ellis@gmail.com>
2022-08-12 23:53:34 +10:00
..
argcheck.c py: Add option to compile without any error messages at all. 2021-04-27 23:51:52 +10:00
asmarm.c py/asmarm: Add asm_arm_ldrh_reg_reg_offset() helper func. 2022-05-23 14:21:16 +10:00
asmarm.h py/asm: Add ASM_LOAD16_REG_REG_OFFSET macro for load-u16 with offset. 2022-05-23 14:21:16 +10:00
asmbase.c py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
asmbase.h py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
asmthumb.c py/asmthumb: Provide implementations of clz/ctz for msvc. 2022-05-24 22:27:18 +10:00
asmthumb.h py/asmthumb: Make ARMv7-M instruction use dynamically selectable. 2022-05-23 23:01:12 +10:00
asmx64.c py/asmx64: Support full range of regs in asm_x64_lea_disp_to_r64. 2022-05-17 14:25:51 +10:00
asmx64.h py/asm: Add ASM_LOAD16_REG_REG_OFFSET macro for load-u16 with offset. 2022-05-23 14:21:16 +10:00
asmx86.c py/asm: Add funcs/macros to emit machine code for logical-shift-right. 2020-06-27 00:24:04 +10:00
asmx86.h py/asm: Add ASM_LOAD16_REG_REG_OFFSET macro for load-u16 with offset. 2022-05-23 14:21:16 +10:00
asmxtensa.c py/asmxtensa: Fix use of l32i/s32i when offset won't fit in encoding. 2022-03-30 16:32:17 +11:00
asmxtensa.h py/asm: Add ASM_LOAD16_REG_REG_OFFSET macro for load-u16 with offset. 2022-05-23 14:21:16 +10:00
bc.c py/bc: Remove unused mp_opcode_format function. 2022-06-07 13:32:38 +10:00
bc.h py/bc: Remove unused mp_opcode_format function. 2022-06-07 13:32:38 +10:00
bc0.h py: Change jump-if-x-or-pop opcodes to have unsigned offset argument. 2022-03-28 15:43:09 +11:00
binary.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
binary.h
builtin.h py/builtin: Remove unnecessary module declarations. 2022-06-27 22:17:13 +10:00
builtinevex.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
builtinhelp.c py/builtinhelp: Don't show help for an MP_MODULE_ATTR_DELEGATION_ENTRY. 2022-06-28 16:35:01 +10:00
builtinimport.c py/builtinimport: Remove duplicate static function argument. 2022-07-27 11:38:47 +10:00
compile.c py/compile: Support large integers in inline-asm data directive. 2022-07-26 12:24:50 +10:00
compile.h py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
dynruntime.h py/dynruntime: Add macros to access more types and mp_const_empty_bytes. 2022-06-10 16:42:43 +10:00
dynruntime.mk py/dynruntime.mk: Allow building assembly source in natmods. 2022-08-11 14:00:13 +10:00
emit.h py/emit: Remove logic to detect last-emit-was-return-value. 2022-06-20 22:28:18 +10:00
emitbc.c py/emit: Suppress unreachable bytecode/native code that follows jump. 2022-06-20 22:28:18 +10:00
emitcommon.c py/compile: De-duplicate constant objects in module's constant table. 2022-05-18 15:23:11 +10:00
emitglue.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitglue.h py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitinlinethumb.c py/emitinlinethumb: Make float instruction use dynamically selectable. 2022-05-26 12:22:07 +10:00
emitinlinextensa.c py: Use unsigned comparison of chars. 2020-10-22 11:47:36 +02:00
emitnarm.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitnative.c py/emitnative: Fix STORE_ATTR viper code-gen when value is not a pyobj. 2022-07-12 17:18:27 +10:00
emitnthumb.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitnx64.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitnx86.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitnxtensa.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
emitnxtensawin.c py/emitnative: Access qstr values using indirection table qstr_table. 2022-05-23 15:43:06 +10:00
formatfloat.c py/formatfloat: Use pow(10, e) instead of pos/neg_pow lookup tables. 2022-08-12 23:53:34 +10:00
formatfloat.h
frozenmod.c py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
frozenmod.h py/builtin: Clean up and simplify import_stat and builtin_open config. 2022-05-25 13:04:45 +10:00
gc.c py/gc: Reduce code size when MICROPY_GC_SPLIT_HEAP is disabled. 2022-07-23 00:43:08 +10:00
gc.h py/gc: Allow the GC heap to be split over multiple memory areas. 2022-07-23 00:42:54 +10:00
grammar.h py/compile: Implement PEP 526, syntax for variable annotations. 2020-06-16 23:18:01 +10:00
lexer.c py/persistentcode: Remove unicode feature flag from .mpy file. 2022-05-17 12:51:54 +10:00
lexer.h py/builtin: Clean up and simplify import_stat and builtin_open config. 2022-05-25 13:04:45 +10:00
make_root_pointers.py py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator. 2022-07-18 13:48:23 +10:00
makecompresseddata.py py/makecompresseddata.py: Make compression deterministic. 2020-04-20 10:32:49 +10:00
makemoduledefs.py py/makemoduledefs.py: Emit useful error for legacy MP_REGISTER_MODULE. 2022-06-14 15:05:37 +01:00
makeqstrdata.py py/qstr: Separate hash and len from string data. 2022-02-11 22:52:32 +11:00
makeqstrdefs.py py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator. 2022-07-18 13:48:23 +10:00
makeversionhdr.py py/makeversionhdr: Add --tags arg to git describe. 2021-07-05 10:41:31 -05:00
malloc.c py/malloc: Introduce m_tracked_calloc, m_tracked_free functions. 2022-05-05 10:31:50 +10:00
map.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
misc.h py/formatfloat: Use pow(10, e) instead of pos/neg_pow lookup tables. 2022-08-12 23:53:34 +10:00
mkenv.mk all: Fix paths to mpy-cross and micropython binaries. 2022-08-11 13:31:13 +10:00
mkrules.cmake all: Fix paths to mpy-cross and micropython binaries. 2022-08-11 13:31:13 +10:00
mkrules.mk py/mkrules: Use abspath to find directory for mpy-cross dependency. 2022-08-12 16:38:24 +10:00
modarray.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modbuiltins.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modcmath.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modcollections.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modgc.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modio.c py/modio: Remove FileIO and TextIOWrapper from io module. 2022-07-26 17:58:01 +10:00
modmath.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modmicropython.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modstruct.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
modsys.c py/modsys: Use MP_REGISTER_ROOT_POINTER(). 2022-07-18 13:52:01 +10:00
modthread.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
moduerrno.c all: Remove third argument to MP_REGISTER_MODULE. 2022-06-02 16:31:37 +10:00
mpconfig.h py/objstr: Add hex/fromhex to bytes/memoryview/bytearray. 2022-08-12 12:44:30 +10:00
mperrno.h py/mperrno: Add MP_ECANCELED error code. 2021-06-24 23:14:01 +10:00
mphal.h all: Rename absolute time-based functions to include "epoch". 2020-09-18 17:20:34 +10:00
mpprint.c py/mpprint: Fix length calculation for strings with precision-modifier. 2020-12-07 23:32:06 +11:00
mpprint.h py/mpprint: Fix formatting typo with mp_print_ext_t struct name. 2022-08-10 14:30:47 +10:00
mpstate.c
mpstate.h py/gc: Reduce code size when MICROPY_GC_SPLIT_HEAP is disabled. 2022-07-23 00:43:08 +10:00
mpthread.h
mpz.c py/mpz: Fix bugs with bitwise of -0 by ensuring all 0's are positive. 2021-12-21 18:00:05 +11:00
mpz.h py/mpz: Fix bugs with bitwise of -0 by ensuring all 0's are positive. 2021-12-21 18:00:05 +11:00
nativeglue.c py/bc: Provide separate code-state setup funcs for bytecode and native. 2022-05-17 14:25:51 +10:00
nativeglue.h py/bc: Provide separate code-state setup funcs for bytecode and native. 2022-05-17 14:25:51 +10:00
nlr.c
nlr.h all: Reformat remaining C code that doesn't have a space after a comma. 2022-05-05 13:30:40 +10:00
nlraarch64.c py/nlraarch64: Add underscore prefix to function symbols for Darwin ABI. 2021-05-18 11:46:30 +10:00
nlrpowerpc.c py/nlrpowerpc: Fix generation of ppc64 code on ppc32 build. 2022-08-11 14:04:13 +10:00
nlrsetjmp.c
nlrthumb.c
nlrx64.c py/nlrx64: Correct the detection of Darwin ABI. 2021-05-18 11:52:00 +10:00
nlrx86.c
nlrxtensa.c
obj.c py/obj: Make mp_obj_get_complex_maybe call mp_obj_get_float_maybe first. 2022-07-25 16:11:26 +10:00
obj.h py/objstr: Consolidate methods for str/bytes/bytearray/array. 2022-08-11 23:18:02 +10:00
objarray.c py/objstr: Add hex/fromhex to bytes/memoryview/bytearray. 2022-08-12 12:44:30 +10:00
objarray.h py/objstr: Consolidate methods for str/bytes/bytearray/array. 2022-08-11 23:18:02 +10:00
objattrtuple.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objbool.c
objboundmeth.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objcell.c py/objcell: Make cell get/set funcs static-inline to reduce code size. 2022-06-20 23:37:38 +10:00
objclosure.c py/objclosure: Forward function attributes for closures. 2022-06-24 23:46:59 +10:00
objcomplex.c py/obj: Make mp_obj_get_complex_maybe call mp_obj_get_float_maybe first. 2022-07-25 16:11:26 +10:00
objdeque.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objdict.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objenumerate.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objexcept.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
objexcept.h
objfilter.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objfloat.c py/parsenum: Optimise when building with complex disabled. 2022-06-23 11:46:47 +10:00
objfun.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
objfun.h py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
objgenerator.c py/emitnative: Put a pointer to the native prelude in child_table array. 2022-05-17 16:44:49 +10:00
objgenerator.h
objgetitemiter.c py: Support single argument to optimised MP_OBJ_STOP_ITERATION. 2021-07-15 00:12:41 +10:00
objint.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
objint.h py/modsys: Use consistent naming pattern for module-level const objects. 2020-05-28 10:02:14 +10:00
objint_longlong.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
objint_mpz.c py/obj: Add static safety checks to mp_obj_is_type(). 2022-07-18 11:17:46 +10:00
objlist.c extmod/modujson: Add support for dump/dumps separators keyword-argument. 2021-08-07 13:52:16 +10:00
objlist.h
objmap.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objmodule.c py: Change makemoduledefs process so it uses output of qstr extraction. 2022-06-02 16:29:53 +10:00
objmodule.h py/objmodule: Support delegating failed attr lookups. 2022-03-10 10:35:44 +11:00
objnamedtuple.c py/objnamedtuple: Fix segfault with empty namedtuple. 2022-07-13 16:25:35 +10:00
objnamedtuple.h
objnone.c
objobject.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objpolyiter.c
objproperty.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objrange.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objreversed.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objset.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objsingleton.c
objslice.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objstr.c py/objstr: Add hex/fromhex to bytes/memoryview/bytearray. 2022-08-12 12:44:30 +10:00
objstr.h py/objstr: Remove str function object declarations from header file. 2022-08-12 16:38:22 +10:00
objstringio.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objstringio.h
objstrunicode.c py/objstr: Consolidate methods for str/bytes/bytearray/array. 2022-08-11 23:18:02 +10:00
objtuple.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
objtuple.h
objtype.c py/obj: Add support for __float__ and __complex__ functions. 2022-07-25 14:23:34 +10:00
objtype.h
objzip.c all: Use mp_obj_malloc everywhere it's applicable. 2022-05-03 22:28:14 +10:00
opmethods.c
pairheap.c
pairheap.h
parse.c py/parsenum: Optimise when building with complex disabled. 2022-06-23 11:46:47 +10:00
parse.h py/parse: Factor obj extract code to mp_parse_node_extract_const_object. 2022-04-14 22:44:56 +10:00
parsenum.c py/parsenum: Ensure that trailing zeros lead to identical results. 2022-08-12 23:44:11 +10:00
parsenum.h py/parsenum: Optimise when building with complex disabled. 2022-06-23 11:46:47 +10:00
parsenumbase.c
parsenumbase.h
persistentcode.c py/persistentcode: Use MP_REGISTER_ROOT_POINTER(). 2022-07-18 13:52:01 +10:00
persistentcode.h py/persistentcode: Select ARMV6M as maximum when __thumb2__ not defined. 2022-05-23 23:01:25 +10:00
profile.c py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
profile.h py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
py.cmake py/py.cmake: Introduce MICROPY_INC_CORE as a list with core includes. 2021-04-09 13:08:35 +10:00
py.mk py/make_root_pointers: Add MP_REGISTER_ROOT_POINTER parser/generator. 2022-07-18 13:48:23 +10:00
pystack.c py: Introduce and use mp_raise_type_arg helper. 2021-07-15 00:12:41 +10:00
pystack.h
qstr.c py/qstr: Change qstr hash type from mp_uint_t to size_t. 2022-08-11 23:18:02 +10:00
qstr.h py/qstr: Change qstr hash type from mp_uint_t to size_t. 2022-08-11 23:18:02 +10:00
qstrdefs.h py/modsys: Add optional mutable attributes sys.ps1/ps2 and use them. 2022-03-10 10:58:33 +11:00
reader.c
reader.h
repl.c shared/readline: Make tab insert an indent when it follows whitespace. 2022-04-22 17:00:16 +10:00
repl.h py/modsys: Add optional mutable attributes sys.ps1/ps2 and use them. 2022-03-10 10:58:33 +11:00
ringbuf.c
ringbuf.h extmod/modbluetooth: Make modbluetooth event not a bitfield. 2020-06-05 14:04:20 +10:00
runtime.c py/runtime: Fix crash in star arg unpacking. 2022-08-06 11:32:58 -05:00
runtime.h py/scheduler: De-inline and fix race with pending exception / scheduler. 2022-07-12 15:54:33 +10:00
runtime0.h py/obj: Add support for __float__ and __complex__ functions. 2022-07-25 14:23:34 +10:00
runtime_utils.c
scheduler.c py/scheduler: Use MP_REGISTER_ROOT_POINTER(). 2022-07-18 13:52:01 +10:00
scope.c py: Rework bytecode and .mpy file format to be mostly static data. 2022-02-24 18:08:43 +11:00
scope.h py/emitcommon: Don't implicitly close class vars that are assigned to. 2022-05-03 16:38:43 +10:00
sequence.c
showbc.c py: Change jump-if-x-or-pop opcodes to have unsigned offset argument. 2022-03-28 15:43:09 +11:00
smallint.c
smallint.h py/smallint: Introduce MP_SMALL_INT_BITS macro. 2022-03-25 12:23:43 +11:00
stackctrl.c
stackctrl.h py/stackctrl: Prevent unused-var warning when stack checking disabled. 2021-06-05 11:03:09 +10:00
stream.c py/stream: Remove mp_stream_errno and use system errno instead. 2020-04-27 23:58:46 +10:00
stream.h
unicode.c
unicode.h
usermod.cmake rp2: Add support for USER_C_MODULES to CMake build system. 2021-03-31 00:26:01 +11:00
vm.c py/vm: Consistently indent #if guards to match the code they surround. 2022-07-12 22:48:55 +10:00
vmentrytable.h py/vmentrytable: Ignore GCC -Woverride-init. 2020-10-22 11:47:36 +02:00
vstr.c
warning.c