pypy /pypy/module/binascii/interp_crc32.py

Language Python Lines 13
MD5 Hash b383b83724d161fa21144d2cb6b89e01 Estimated Cost $192 (why?)
Repository https://bitbucket.org/pypy/pypy/ View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from pypy.interpreter.gateway import unwrap_spec
from rpython.rtyper.lltypesystem import rffi
from rpython.rlib.rarithmetic import r_uint, intmask
from rpython.rlib import rzipfile

@unwrap_spec(data='bufferstr', oldcrc='truncatedint_w')
def crc32(space, data, oldcrc=0):
    "Compute the CRC-32 incrementally."

    crc = rzipfile.crc32(data, r_uint(oldcrc))
    crc = rffi.cast(rffi.INT, crc)    # unsigned => 32-bit signed
    return space.wrap(intmask(crc))
Back to Top