PageRenderTime 84ms CodeModel.GetById 40ms app.highlight 8ms RepoModel.GetById 33ms app.codeStats 0ms

/pypy/module/binascii/interp_crc32.py

https://bitbucket.org/pypy/pypy/
Python | 12 lines | 10 code | 2 blank | 0 comment | 0 complexity | b383b83724d161fa21144d2cb6b89e01 MD5 | raw file
 1from pypy.interpreter.gateway import unwrap_spec
 2from rpython.rtyper.lltypesystem import rffi
 3from rpython.rlib.rarithmetic import r_uint, intmask
 4from rpython.rlib import rzipfile
 5
 6@unwrap_spec(data='bufferstr', oldcrc='truncatedint_w')
 7def crc32(space, data, oldcrc=0):
 8    "Compute the CRC-32 incrementally."
 9
10    crc = rzipfile.crc32(data, r_uint(oldcrc))
11    crc = rffi.cast(rffi.INT, crc)    # unsigned => 32-bit signed
12    return space.wrap(intmask(crc))