Yes, it is exactly as ai_curious says: z is a reference to an object (numpy array), so it is passed by reference on the procedure call. If you directly modify z in the function without first copying it, you are modifying the global data. Not a good idea. See this thread for some more discussion of this point with a detailed example showing the behavior.
It was also explained with some other links earlier in this thread. What is the point of finding the thread if you don’t actually read it? He asked rhetorically …