-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
WIP py/objint.c: Add signed
param to int.from_bytes().
#16798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
|
Code size report:
|
8f7925d
to
f3403bb
Compare
@projectgus @dpgeorge @robert-hh Need a help.
Thanks. |
f3403bb
to
9957726
Compare
signed
param to int.from_bytes().
See also #16311 |
I think the error you have here may be caused by a partial build failure, you can try doing a clean build and see if it goes away. However I'm not certain every longint implementation works on every port. |
The same errors remain. :( |
As well as changing the constant in I think for esp32 port this will mean something like adding |
2f466fd
to
4977a78
Compare
44e5e3c
to
090cfca
Compare
Support signed param: result = int.from_bytes(bytearray(), order='big'|'little', signed=False|True) Add `length`, `byteorder`, `signed` according to the micropython#16311. Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
090cfca
to
0489c31
Compare
Summary
Support
signed=True
param:result = int.from_bytes(bytearray(), byteorder='big'|'little', signed=False|True)
Testing
test_int.py
Added:
micropython/tests/basics/int_from_bytes.py
Tested on ESP32, ESP32-S2 boards.
Trade-offs and Alternatives
The length of the byte array is limited to
sizeof(mp_longint_impl_t)
in this PR.int.from_bytes(bytes(20)) will raise OverflowError: big-int overflow