MCPcopy Index your code
hub / github.com/python/cpython / decode_long

Function decode_long

Lib/pickle.py:402–420  ·  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

400 return result
401
402def decode_long(data):
403 r"""Decode a long from a two's complement little-endian binary string.
404
405 >>> decode_long(b'')
406 0
407 >>> decode_long(b"\xff\x00")
408 255
409 >>> decode_long(b"\xff\x7f")
410 32767
411 >>> decode_long(b"\x00\xff")
412 -256
413 >>> decode_long(b"\x00\x80")
414 -32768
415 >>> decode_long(b"\x80")
416 -128
417 >>> decode_long(b"\x7f")
418 127
419 """
420 return int.from_bytes(data, byteorder='little', signed=True)
421
422def _T(obj):
423 cls = type(obj)

Callers 4

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

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…