MCPcopy Index your code
hub / github.com/RustPython/RustPython / decode_long

Function decode_long

Lib/pickle.py:386–404  ·  view source on GitHub ↗

r"""Decode a long from a two's complement little-endian binary string. >>> decode_long(b'') 0 >>> decode_long(b"\xff\x00") 255 >>> decode_long(b"\xff\x7f") 32767 >>> decode_long(b"\x00\xff") -256 >>> decode_long(b"\x00\x80") -32768 >>> decode_long(b"\x80"

(data)

Source from the content-addressed store, hash-verified

384 return result
385
386def decode_long(data):
387 r"""Decode a long from a two's complement little-endian binary string.
388
389 >>> decode_long(b'')
390 0
391 >>> decode_long(b"\xff\x00")
392 255
393 >>> decode_long(b"\xff\x7f")
394 32767
395 >>> decode_long(b"\x00\xff")
396 -256
397 >>> decode_long(b"\x00\x80")
398 -32768
399 >>> decode_long(b"\x80")
400 -128
401 >>> decode_long(b"\x7f")
402 127
403 """
404 return int.from_bytes(data, byteorder='little', signed=True)
405
406def _T(obj):
407 cls = type(obj)

Callers 4

read_long1Function · 0.90
read_long4Function · 0.90
load_long1Method · 0.85
load_long4Method · 0.85

Calls 1

from_bytesMethod · 0.45

Tested by

no test coverage detected