From: Stefan v. d. W. <st...@su...> - 2006-10-13 15:22:18
|
Hi all, I've noticed that 'astype' always forces a copy. Is this behaviour intended? It seems to conflict with 'asarray', that tries to avoid a copy. For example, when wrapping code in ctypes, the following snippet would have been useful: def foo(x): # ensure x is an array of the right type x =3D N.ascontiguousarray(x).astype(N.intc) but that will cause a copy, so you'll have to do def foo(x): try: x =3D N.ascontiguousarray(x,N.intc) except: x =3D N.ascontiguousarray(x).astype(N.intc) Maybe I'm missing something obvious here -- any pointers? Thanks St=E9fan |