I am writing a C extension for Python, which should release the Global Interpreter Lock while it operates on data. I think I have understood the mechanism of the GIL fairly
Can I access data in a Python object while the thread does not own the GIL?
No you cannot.
Is this safe?
Strictly, no. I think you should move the calls to PyArray_SIZE and PyArray_DATA outside the GIL-less block; if you do that, you'll be operating on C data only. You might also want to increment the reference count on the object before going into the GIL-less block and decrement it afterwards.
After your edits, it should be safe. Don't forget to decrement the reference count afterwards.