py/objint: from_bytes(): Implement "byteorder" param and arbitrary precision.

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().
diff --git a/py/objint.c b/py/objint.c
index 5842a00..a61ed8e 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -374,26 +374,33 @@
 
 // this is a classmethod
 STATIC mp_obj_t int_from_bytes(size_t n_args, const mp_obj_t *args) {
-    // TODO: Support long ints
-    // TODO: Support byteorder param
     // TODO: Support signed param (assumes signed=False at the moment)
     (void)n_args;
 
-    if (args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little)) {
-        mp_not_implemented("");
-    }
-
     // get the buffer info
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
 
-    // convert the bytes to an integer
-    mp_uint_t value = 0;
-    for (const byte* buf = (const byte*)bufinfo.buf + bufinfo.len - 1; buf >= (byte*)bufinfo.buf; buf--) {
-        value = (value << 8) | *buf;
-    }
+    #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
+    // If result guaranteedly fits in small int, use that
+    if (!MP_SMALL_INT_FITS(1 << (bufinfo.len * 8 - 1))) {
+        return mp_obj_int_from_bytes_impl(args[2] != MP_OBJ_NEW_QSTR(MP_QSTR_little), bufinfo.len, bufinfo.buf);
+    } else
+    #endif
+    {
+        const byte* buf = (const byte*)bufinfo.buf;
+        int delta = 1;
+        if (args[2] == MP_OBJ_NEW_QSTR(MP_QSTR_little)) {
+            buf += bufinfo.len - 1;
+            delta = -1;
+        }
 
-    return mp_obj_new_int_from_uint(value);
+        mp_uint_t value = 0;
+        for (; bufinfo.len--; buf += delta) {
+            value = (value << 8) | *buf;
+        }
+        return mp_obj_new_int_from_uint(value);
+    }
 }
 
 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(int_from_bytes_fun_obj, 3, 4, int_from_bytes);