summaryrefslogtreecommitdiffstatshomepage
path: root/py/objint.c
Commit message (Collapse)AuthorAge
* py: Rename mp_obj_int_get to mp_obj_int_get_truncated; fix struct.pack.Damien George2014-12-05
| | | | | | | | | | | 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.
* py: Make int.to_bytes work on big endian machine.Damien George2014-10-06
| | | | Partly addresses issue #856.
* py: Convert [u]int to mp_[u]int_t where appropriate.Damien George2014-10-03
| | | | Addressing issue #50.
* py: Enable struct/binary-helper to parse q and Q sized ints.Damien George2014-09-10
| | | | Addresses issue #848.
* py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Change all uint to mp_uint_t in obj.h.Damien George2014-08-30
| | | | Part of code cleanup, working towards resolving issue #50.
* py: Save about 200 bytes of ROM by using smaller type for static table.Damien George2014-08-30
|
* Change some parts of the core API to use mp_uint_t instead of uint/int.Damien George2014-08-30
| | | | Addressing issue #50, still some way to go yet.
* py: Improve efficiency of MP_OBJ_IS_STR_OR_BYTES.Damien George2014-08-27
| | | | | Saves ROM (16 on stmhal, 240 on 64-bit unix) and should be quicker since there is 1 less branch.
* Make int(b'123') work properly.Dave Hylands2014-08-26
|
* py: Fix mult by negative number of tuple, list, str, bytes.Damien George2014-08-13
| | | | | | | Multiplication of a tuple, list, str or bytes now yields an empty sequence (instead of crashing). Addresses issue #799 Also added ability to mult bytes on LHS by integer.
* py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.Damien George2014-07-31
| | | | Addresses issue #724.
* py: Make long ints hashable.Damien George2014-07-24
| | | | Addresses issue #765.
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* objint: Fix corner case in buffer access.Paul Sokolovsky2014-06-06
|
* Rename bultins config variables to MICROPY_PY_BUILTINS_*.Damien George2014-06-01
| | | | | | | | | | This renames: MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT See issue #35 for discussion.
* py: Fix check of small-int overflow when parsing ints.Damien George2014-05-28
| | | | Also unifies use of SMALL_INT_FITS macro across parser and runtime.
* py: Make int(<longint>) work by just returning the longint.Damien George2014-05-28
|
* py: Implement long int parsing in int(...).Damien George2014-05-28
| | | | Addresses issue #627.
* py: Rename MP_OBJ_NOT_SUPPORTED to MP_OBJ_NULL.Damien George2014-05-21
| | | | See issue #608 for justification.
* py: Fix mp_obj_t -> mp_const_obj_t for mp_obj_int_get_checked()Sven Wegener2014-05-17
| | | | Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
* py: More const usage.Paul Sokolovsky2014-05-17
|
* py: Use mp_arg_check_num in more places.Damien George2014-05-11
| | | | | | | | | Updated functions now do proper checking that n_kw==0, and are simpler because they don't have to explicitly raise an exception. Down side is that the error messages no longer include the function name, but that's acceptable. Saves order 300 text bytes on x64 and ARM.
* Windows MSVC portstijn2014-05-08
| | | | Extend the windows port so it compiles with the toolchain from Visual Studio 2013
* py: Improve native emitter; now supports more opcodes.Damien George2014-05-07
|
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
* py, unix: Make "mpconfig.h" be first included, as other headers depend on it.Paul Sokolovsky2014-05-02
| | | | Specifically, nlr.h does.
* py: Allow to pass buffer protocol flags to get_buffer helper funcs.Damien George2014-04-18
|
* py: Add typecode to buffer protocol.Damien George2014-04-18
| | | | | | | When querying an object that supports the buffer protocol, that object must now return a typecode (as per binary.[ch]). This does not have to be honoured by the caller, but can be useful for determining element size.
* py: Add MP_OBJ_STOP_ITERATION and make good use of it.Damien George2014-04-17
| | | | | Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
* py: Oops, fix int.from_bytes to correctly convert bytes!Damien George2014-04-13
|
* py: Make int.from_bytes a classmethod; support arbitrary length buf.Damien George2014-04-13
|
* py: Make it so that printing a small int does not allocate heap memory.Damien George2014-04-08
| | | | | | | | | | | | | | With the implementation of proper string formatting, code to print a small int was delegated to mpz_as_str_inpl (after first converting the small int to an mpz using stack memory). But mpz_as_str_inpl allocates heap memory to do the conversion, so small ints needed heap memory just to be printed. This fix has a separate function to print small ints, which does not allocate heap, and allocates less stack. String formatting, printf and pfenv are now large beasts, with some semi-duplicated code.
* objint: Implement int.from_bytes() class method and .to_bytes() method.Paul Sokolovsky2014-04-09
| | | | | | | These two are apprerently the most concise and efficient way to convert int to/from bytes in Python. The alternatives are struct and array modules, but methods using them are more verbose in Python code and less efficient in memory/cycles.
* Fix truncation problem when using longlong implementation.Dave Hylands2014-04-07
|
* Add string formatting support for longlong and mpz.Dave Hylands2014-04-07
|
* py: Change nlr_jump to nlr_raise, to aid in debugging.Damien George2014-04-05
| | | | | | This does not affect code size or performance when debugging turned off. To address issue #420.
* py: Make False and True act like 0 and 1 for integer arithmetic.Damien George2014-04-04
|
* py: Allow multiple of str/list/tuple on left by an integer.Damien George2014-04-02
|
* py: Add explicit conversion from float to int via int().Damien George2014-03-30
|
* py: Rename old const type objects to mp_type_* for consistency.Damien George2014-03-29
|
* py: Add function to convert long int to float.Damien George2014-03-22
|
* py: Clean up includes.xbe2014-03-17
| | | | Remove unnecessary includes. Add includes that improve portability.
* py: Implement integer overflow checking for * and << ops.Damien George2014-03-12
| | | | If operation will overflow, a multi-precision integer is created.
* Add arbitrary precision integer support.Damien George2014-02-22
| | | | | Some functionality is still missing (eg and, or, bit shift), and some things are buggy (eg subtract).
* py: Put number parsing code together in parsenum.c.Damien George2014-02-22
|
* py: Rename strtonum to mp_strtonum.Damien George2014-02-22
| | | | | strtonum clashes with BSD function of same name, and our version is different so warrants a unique name. Addresses Issue #305.
* py: Fix casting and printing of small int.Damien George2014-02-22
|
* Implement proper exception type hierarchy.Damien George2014-02-15
| | | | | | | | | | | | | | Each built-in exception is now a type, with base type BaseException. C exceptions are created by passing a pointer to the exception type to make an instance of. When raising an exception from the VM, an instance is created automatically if an exception type is raised (as opposed to an exception instance). Exception matching (RT_BINARY_OP_EXCEPTION_MATCH) is now proper. Handling of parse error changed to match new exceptions. mp_const_type renamed to mp_type_type for consistency.
* Change mp_obj_type_t.name from const char * to qstr.Damien George2014-02-15
| | | | | | 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.