ENH use memcopy instead of while loop