[pypy-commit] pypy default: Unmarshal longs using the new from_list_n_bits().

arigo noreply at buildbot.pypy.org
Sun Nov 10 16:08:38 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r67931:31ea0b839ffc
Date: 2013-11-10 16:06 +0100
http://bitbucket.org/pypy/pypy/changeset/31ea0b839ffc/

Log:	Unmarshal longs using the new from_list_n_bits().

diff --git a/pypy/objspace/std/marshal_impl.py b/pypy/objspace/std/marshal_impl.py
--- a/pypy/objspace/std/marshal_impl.py
+++ b/pypy/objspace/std/marshal_impl.py
@@ -230,11 +230,8 @@
         lng = -lng
     else:
         negative = False
-    SHIFT = 15
-    result = rbigint.fromint(0)
-    for i in range(lng):
-        shift = i * SHIFT
-        result = result.or_(rbigint.fromint(u.get_short()).lshift(shift))
+    digits = [u.get_short() for i in range(lng)]
+    result = rbigint.from_list_n_bits(digits, 15)
     if lng and not result.tobool():
         raise_exception(space, 'bad marshal data')
     if negative:


More information about the pypy-commit mailing list