diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-09-18 00:06:43 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-09-18 00:06:43 +0300 |
commit | 9dce823cfd0a9991350184f08a1373f3887134f4 (patch) | |
tree | 214ca2cd6d0a6c2a93f3f76dd2f5c76857f3a49f /py/objint.h | |
parent | 72491b3e40db75e7edf5831e8914a1ca5c8e9937 (diff) |
py/modbuiltins: Implement abs() by dispatching to MP_UNARY_OP_ABS.
This allows user classes to implement __abs__ special method, and saves
code size (104 bytes for x86_64), even though during refactor, an issue
was fixed and few optimizations were made:
* abs() of minimum (negative) small int value is calculated properly.
* objint_longlong and objint_mpz avoid allocating new object is the
argument is already non-negative.
Diffstat (limited to 'py/objint.h')
-rw-r--r-- | py/objint.h | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/py/objint.h b/py/objint.h index a4d4ff32d..4b95acde9 100644 --- a/py/objint.h +++ b/py/objint.h @@ -57,7 +57,6 @@ mp_int_t mp_obj_int_hash(mp_obj_t self_in); mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf); void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf); int mp_obj_int_sign(mp_obj_t self_in); -mp_obj_t mp_obj_int_abs(mp_obj_t self_in); mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in); mp_obj_t mp_obj_int_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); mp_obj_t mp_obj_int_binary_op_extra_cases(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in); |