<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def arrayFactory(shape, dtype=float):
 	""" 	Creates a new ndarray of the specified shape and datatype, storing 	it in memory if there is sufficient available space or else using 	a memory-mapped temporary file to provide the underlying buffer. 	"""

	
	# Determine the number of bytes required to store the array
	requiredBytes = _requiredSize(shape, dtype)
	
	# Determine if there is sufficient available memory
	vmem = psutil.virtual_memory()
	if vmem.available > requiredBytes:
		return np.ndarray(shape=shape, dtype=dtype)
	else:
		return TempfileBackedArray(shape=shape, dtype=dtype)