| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
| |
This allows running `py/makeqstrdata.py` with MicroPython itself.
Signed-off-by: Volodymyr Shymanskyy <vshymanskyi@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
|
|
|
|
|
|
|
|
| |
Originally implemented in a patch file provided by @ironss-iotec.
Fixes issue #14093.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This disables using qstr hashes altogether, which saves RAM and flash
(two bytes per interned string on a typical build) as well as code size.
On PYBV11 this is worth over 3k flash.
qstr comparison will now be done just by length then data. This affects
qstr_find_strn although this has a negligible performance impact as, for a
given comparison, the length and first character will ~usually be
different anyway.
String hashing (e.g. builtin `hash()` and map.c) now need to compute the
hash dynamically, and for the map case this does come at a performance
cost.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This provides a significant performance boost for qstr_find_strn, which is
called a lot during parsing and loading of .mpy files, as well as interning
of string objects (which happens in most string methods that return new
strings).
Also adds comments to explain the "static" qstrs. These are part of the
.mpy ABI and avoid needing to duplicate string data for QSTRs known to
already be in the firmware. The static pool isn't currently sorted, but in
the future we could either split the static pool into the sorted regions,
or in the next .mpy version just sort them.
Based on initial work done by @amirgon in #6896.
This work was funded through GitHub Sponsors.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
| |
See https://black.readthedocs.io/en/stable/the_black_code_style/index.html
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows the compiler to merge strings: e.g. "update",
"difference_update" and "symmetric_difference_update" will all point to the
same memory.
No functional change.
The size reduction depends on the number of qstrs in the build. The change
this commit brings is:
bare-arm: -4 -0.007%
minimal x86: +150 +0.092% [incl +48(data)]
unix x64: -608 -0.118%
unix nanbox: -572 -0.126% [incl +32(data)]
stm32: -1392 -0.352% PYBV10
cc3200: -448 -0.244%
esp8266: -1208 -0.173% GENERIC
esp32: -1028 -0.068% GENERIC[incl -1020(data)]
nrf: -440 -0.252% pca10040
rp2: -1072 -0.217% PICO
samd: -368 -0.264% ADAFRUIT_ITSYBITSY_M4_EXPRESS
Performance is also improved (on bare metal at least) for the
core_import_mpy_multi.py, core_import_mpy_single.py and core_qstr.py
performance benchmarks.
Originally at adafruit#4583
Signed-off-by: Artyom Skrobov <tyomitch@gmail.com>
|
|
|
|
| |
This is run with uncrustify 0.70.1, and black 19.10b0.
|
|
|
|
| |
Fixes #5140.
|
| |
|
|
|
|
|
|
|
|
| |
When encoded in the mpy file, if qstr <= QSTR_LAST_STATIC then store two
bytes: 0, static_qstr_id. Otherwise encode the qstr as usual (either with
string data or a reference into the qstr window).
Reduces mpy file size by about 5%.
|
|
|
|
|
| |
If MICROPY_PY_ALL_SPECIAL_METHODS is enabled then dir() will now delegate
to the special method __dir__ if the object it is listing has this method.
|
|
|
|
|
|
| |
Update makeqstrdata.py to sort strings starting with "__" to the beginning
of qstr list, so they get low qstr id's, guaranteedly fitting in 8 bits.
Then use this property to further compact op_id => qstr mapping arrays.
|
| |
|
|
|
|
|
| |
When rendering the qstr for a C header file, the double-quate character
must be escaped.
|
| |
|
| |
|
|
|
|
|
| |
The qstr data needs to be turned into a proper C string so non-ASCII
chars must be properly escaped according to C rules.
|
|
|
|
|
| |
Non-printable characters are escaped as 0xXX, where XX are the hex
digits of the character value.
|
| |
|
|
|
|
| |
The usual cause would be that a cross-compiler for a port is not in PATH.
|
|
|
|
|
|
| |
Fetch the current usb mode and return a string representation when
pyb.usb_mode() is called with no args. The possible string values are interned
as qstr's. None will be returned if an incorrect mode is set.
|
| |
|
|
|
|
|
|
|
| |
This patch makes configurable, via MICROPY_QSTR_BYTES_IN_HASH, the
number of bytes used for a qstr hash. It was originally fixed at 2
bytes, and now defaults to 2 bytes. Setting it to 1 byte will save
ROM and RAM at a small expense of hash collisions.
|
|
|
|
|
| |
These scripts should run under as wide a range of Python versions as
possible.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This new config option sets how many fixed-number-of-bytes to use to
store the length of each qstr. Previously this was hard coded to 2,
but, as per issue #1056, this is considered overkill since no-one
needs identifiers longer than 255 bytes.
With this patch the number of bytes for the length is configurable, and
defaults to 1 byte. The configuration option filters through to the
makeqstrdata.py script.
Code size savings going from 2 to 1 byte:
- unix x64 down by 592 bytes
- stmhal down by 1148 bytes
- bare-arm down by 284 bytes
Also has RAM savings, and will be slightly more efficient in execution.
|
| |
|
| |
|
|
|
|
|
| |
Script is equivalent, but now also runs under ancient Python 2.6.
Goes part way to addressing issue #847.
|
| |
|
|
|
|
|
|
|
|
|
| |
The original parsing would error out on any C declarations that are not typedefs
or extern variables. This limits what can go in mpconfig.h and mpconfigport.h,
as they are included in qstr.h. For instance even a function declaration would be
rejected and including system headers is a complete no-go.
That seems too limiting for a global config header, so makeqstrdata now
ignores everything that does not match a qstr definition.
|
| |
|
| |
|
|
|
|
| |
I was too hasty. Still a one-liner though.
|
|
|
|
| |
A one-liner, added especially for @pfalcon :)
|
| |
|
| |
|
|
|
|
|
| |
These largely duplicate str() & bytes() constructors' functionality,
but can be used to achieve Python2 compatibility.
|
|
|
|
|
| |
This is alternative implementation of supporting conditionals in qstrdefs.h,
hard to say if it's much cleaner than munging #ifdef's in Python code...
|
|
|
|
|
|
| |
This reverts commit acb133d1b1a68847bd85c545312c3e221a6f7c0b.
Conditionals will be suported using C preprocessor.
|
|
|
|
| |
Syntax is usual C #if*/#endif, but each qstr must be wrapped individually.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
This is compatible with what search path was before sys.path refactor,
with addition of module library path ("0:/lib").
|
|
|
|
|
|
| |
Ultimately all static strings should be qstr. This entry in the type
structure is only used for printing error messages (to tell the type of
the bad argument), and printing objects that don't supply a .print method.
|
|
|
|
|
| |
Want common qstrs to be first in the list so they have the lowest ids,
so that in the byte code they take up the least room.
|
|
|
|
|
| |
Also, add qstr's for string appearing in unix REPL loop, gross effect
being less allocations for each command run.
|
| |
|