Closed neishm closed 5 years ago
I asked @djamelghb about this. It looks like librmn's crc32 duplicates zlib's. Could Python-RPN switch to using the crc32 function in the standard library (https://docs.python.org/library/zlib.html#zlib.crc32)?
I just ran a simple test to compare the two methods, and it looks like yes, it can be switched to zlib. Test code:
import rpnpy.librmn.all as rmn
import zlib
import numpy as np
for i in range(10):
buf = np.random.randint(1<<32,size=1000,dtype='uint32')
crc0 = np.random.randint(1<<32,dtype='uint32')
from_rmn = rmn.crc32(crc0,buf)
from_zlib = zlib.crc32(buf,crc0) & 0xffffffff
print "%08x %08x %s"%(from_rmn, from_zlib, from_rmn == from_zlib)
Result:
776a3602 776a3602 True
87c57921 87c57921 True
3211a345 3211a345 True
4be42d64 4be42d64 True
ee23d303 ee23d303 True
6a9fa480 6a9fa480 True
b484f849 b484f849 True
099663b5 099663b5 True
f0e5d259 f0e5d259 True
7b92fbae 7b92fbae True
I had to apply the 0xffffffff
as mentioned in the Python documentation (linked by @jeixav), otherwise it returns a signed integer.
merged into rpnpy_2.1-branch
See: https://github.com/armnlib/librmn/commit/686e512be455beec14426592a8bbc5f58b551286
If Python-RPN is used with librmn 016.3, it immediately fails with an
AttributeError
from ctypes, due to a missingcrc32
symbol.