Please note you don't need
memcpy
, neither in C++ nor in Python, to perform such computations.
See, for instance, this Stack Overflow's question:
"checksum udp calculation python"[
^] to get some insight on how to use ordinary Python language features to compute checksums.