| Commit message (Collapse) | Author | Age |
|
|
|
|
| |
There were several different spellings of MicroPython present in comments,
when there should be only one.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
This patch ensures that int.from_bytes only creates a big-int if necessary,
by checking the value for a small-int overflow as it's being parsed.
|
|
|
|
|
| |
Otherwise the edge case of the most negative integer value will not convert
correctly.
|
| |
|
|
|
|
|
| |
This reduces code duplication and allows to make mp_classify_fp_as_int
static, which reduces code size.
|
| |
|
|
|
|
|
| |
Otherwise -0.0 is classified as a bigint, which for builds without bigints
will lead unexpectedly to an overflow.
|
|
|
|
|
|
|
| |
Some stack is allocated to format ints, and when the int implementation uses
long-long there should be additional stack allocated compared with the other
cases. This patch uses the existing "fmt_int_t" type to determine the
amount of stack to allocate.
|
| |
|
| |
|
|
|
|
|
|
|
| |
If result guaranteedly fits in a small int, it is handled in objint.c.
Otherwise, it is delegated to mp_obj_int_from_bytes_impl(), which should
be implemented by individual objint_*.c, similar to
mp_obj_int_to_bytes_impl().
|
|
|
|
|
| |
One never needs to format integers with a base larger than 16 (but code
can be easily extended beyond this value if needed in the future).
|
|
|
|
|
|
| |
And also simplify it to remove the check for small int. This can be done
because this function is only ever called if the argument is not a small
int.
|
|
|
|
|
| |
CPython requires byteorder arg, make uPy compatible. As we support only
"little", error out on anything else.
|
|
|
|
|
| |
Saves the following number of bytes of code space: 176 for bare-arm, 352
for minimal, 272 for unix x86-64, 140 for stmhal, 120 for esp8266.
|
| |
|
| |
|
|
|
|
|
| |
Using the original WORD_MSBIT_HIGH-logic resulted in errors when the
object model is not REPR_A or REPR_C.
|
|
|
|
|
|
|
|
| |
The first argument to the type.make_new method is naturally a uPy type,
and all uses of this argument cast it directly to a pointer to a type
structure. So it makes sense to just have it a pointer to a type from
the very beginning (and a const pointer at that). This patch makes
such a change, and removes all unnecessary casting to/from mp_obj_t.
|
|
|
|
|
| |
With this patch the n_args parameter is changed type from mp_uint_t to
size_t.
|
|
|
|
|
|
|
| |
This patch changes the type signature of .make_new and .call object method
slots to use size_t for n_args and n_kw (was mp_uint_t. Makes code more
efficient when mp_uint_t is larger than a machine word. Doesn't affect
ports when size_t and mp_uint_t have the same size.
|
| |
|
|
|
|
| |
This function returns the sign (-1, 0 or 1) of the integer object.
|
|
|
|
|
|
|
|
|
| |
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.
This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Hashing is now done using mp_unary_op function with MP_UNARY_OP_HASH as
the operator argument. Hashing for int, str and bytes still go via
fast-path in mp_unary_op since they are the most common objects which
need to be hashed.
This lead to quite a bit of code cleanup, and should be more efficient
if anything. It saves 176 bytes code space on Thumb2, and 360 bytes on
x86.
The only loss is that the error message "unhashable type" is now the
more generic "unsupported type for __hash__".
|
|
|
|
|
|
|
| |
This gets int.to_bytes working for bignum, and also struct.pack with 'q'
and 'Q' args on 32-bit machines.
Addresses issue #1155.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previous to this patch the printing mechanism was a bit of a tangled
mess. This patch attempts to consolidate printing into one interface.
All (non-debug) printing now uses the mp_print* family of functions,
mainly mp_printf. All these functions take an mp_print_t structure as
their first argument, and this structure defines the printing backend
through the "print_strn" function of said structure.
Printing from the uPy core can reach the platform-defined print code via
two paths: either through mp_sys_stdout_obj (defined pert port) in
conjunction with mp_stream_write; or through the mp_plat_print structure
which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
on the platform. The former is only used when MICROPY_PY_IO is defined.
With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...). Code size is also reduced by around 200 bytes on
Thumb2 archs.
|
| |
|
|
|
|
| |
This is so all memory requests go through the same interface.
|
|
|
|
|
|
|
|
|
| |
Previous to this patch, a big-int, float or imag constant was interned
(made into a qstr) and then parsed at runtime to create an object each
time it was needed. This is wasteful in RAM and not efficient. Now,
these constants are parsed straight away in the parser and turned into
objects. This allows constants with large numbers of digits (so
addresses issue #1103) and takes us a step closer to #722.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this patch str/bytes construction is streamlined. Always use a
vstr to build a str/bytes object. If the size is known beforehand then
use vstr_init_len to allocate only required memory. Otherwise use
vstr_init and the vstr will grow as needed. Then use
mp_obj_new_str_from_vstr to create a str/bytes object using the vstr
memory.
Saves code ROM: 68 bytes on stmhal, 108 bytes on bare-arm, and 336 bytes
on unix x64.
|
|
|
|
| |
See issue #699.
|
|
|
|
| |
See issue #699.
|
|
|
|
| |
Addresses issue #1022.
|
| |
|
|
|
|
|
|
|
| |
This fixes conversion when float type has more mantissa bits than small int,
and float value has small exponent. This is for example the case of 32-bit
platform using doubles, and converting value of time.time(). Conversion of
floats with larg exponnet is still not handled correctly.
|
|
|
|
|
|
|
|
|
|
|
| |
mp_obj_int_get_truncated is used as a "fast path" int accessor that
doesn't check for overflow and returns the int truncated to the machine
word size, ie mp_int_t.
Use mp_obj_int_get_truncated to fix struct.pack when packing maximum word
sized values.
Addresses issues #779 and #998.
|
|
|
|
| |
Partly addresses issue #856.
|
|
|
|
| |
Addressing issue #50.
|
|
|
|
| |
Addresses issue #848.
|
|
|
|
| |
Part of code cleanup, working towards resolving issue #50.
|
|
|
|
| |
Part of code cleanup, working towards resolving issue #50.
|
| |
|