lib/mem: Allow memcpy & friends to work on arbitrary-length buffer
- not only multiple of 8. We can do it by using uint8 typed arrays, and it does not hurt performance: In : from wendelin.lib.mem import bzero, memset, memcpy In : A = bytearray(2*1024*1024) In : B = bytearray(2*1024*1024) memcpy(B, A) bzero(A) memset(A, 0xff) old: 718 µs 227 µs / 1116 228 µs / 1055 (*) new: 718 µs 176 µs / 1080 175 µs / 1048 (*) the second number comes from e.g. In : timeit bzero(A) The slowest run took 4.63 times longer than the fastest. This could mean that an intermediate result is being cached 10000 loops, best of 3: 228 µs per loop so the second number is more realistic and says performance stays aproximately the same and only slightly improves.
Showing with 6 additions and 9 deletions