We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5213eb3 commit b9e7ed4Copy full SHA for b9e7ed4
1 file changed
py/objint.c
@@ -277,8 +277,8 @@ STATIC mp_obj_t int_from_bytes(uint n_args, const mp_obj_t *args) {
277
278
// convert the bytes to an integer
279
machine_uint_t value = 0;
280
- for (uint i = 0; i < bufinfo.len; i++) {
281
- value += ((byte*)bufinfo.buf)[i];
+ for (const byte* buf = bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) {
+ value = (value << 8) | *buf;
282
}
283
284
return mp_obj_new_int_from_uint(value);
0 commit comments