You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looks like initialization of each byte goes through C stub call. Initialization of 40MB buffer took about a second on a server with modern intel CPU. Can this be achieved by calling memset? At least zero-filling probably needs some optimized specialization...
The text was updated successfully, but these errors were encountered:
Indeed, this is a naive implementation, and it should be possible to do considerably better. Several possible improvements, some more work than others:
Eliminate allocations from the loop (which currently creates a new fat pointer for each element in unsafe_set)
Eliminate dispatch/branching from the loop (which currently inspects the type representation once per element in Ctypes_memory.stubs and then again in ctypes_write)
Double-check that the ctypes_write function doesn't allocate, and mark it noalloc if so
Eliminate the C-call-per-element by moving the loop into C
(Perhaps) add specialized implementations for commonly-used types. For char we could use memset
At least zero-filling probably needs some optimized specialization...
That would be useful. As it happens, ctypes uses calloc to allocate C arrays, so they're already guaranteed to be zero-filled when no initializer is supplied.
Looks like initialization of each byte goes through C stub call. Initialization of 40MB buffer took about a second on a server with modern intel CPU. Can this be achieved by calling
memset
? At least zero-filling probably needs some optimized specialization...The text was updated successfully, but these errors were encountered: