Re: [Numpy-discussion] Behaviour of copy for structured dtypes with gaps

2019-04-12 Thread Marten van Kerkwijk
It may be relevant at this point to mention that the padding bytes do *not* get copied - so you get a blob with possibly quite a lot of uninitialized data. If anything, that seems a recipe for unexpected results. Are there non-contrived examples where you would *want* this uninitialized blob?

Re: [Numpy-discussion] Behaviour of copy for structured dtypes with gaps

2019-04-12 Thread Daniel Hrisca
Hello all, padding bytes can be relevant (for example hidden data). Why not add a new argument that the user can use to remove padding bytes? On Fri, Apr 12, 2019, 20:01 Stefan van der Walt wrote: > On Fri, 12 Apr 2019 12:13:18 -0400, Allan Haldane wrote: > > I would be much more in favor of

Re: [Numpy-discussion] Behaviour of copy for structured dtypes with gaps

2019-04-12 Thread Stefan van der Walt
On Fri, 12 Apr 2019 12:13:18 -0400, Allan Haldane wrote: > I would be much more in favor of `copy` eliminating padding in the > dtype, if dtypes with different paddings were considered equivalent. > But they are not. This, and the simplicity arguments, are fair points. Option (1) seems like the

Re: [Numpy-discussion] Behaviour of copy for structured dtypes with gaps

2019-04-12 Thread Allan Haldane
I would be much more in favor of `copy` eliminating padding in the dtype, if dtypes with different paddings were considered equivalent. But they are not. Numpy has always treated dtypes with different padding bytes as not-equal, and prints them very differently: >>> a = np.array([1],

Re: [Numpy-discussion] Behaviour of copy for structured dtypes with gaps

2019-04-12 Thread Francesc Alted
I recently put some thought on the issue because a user was complaining about PyTables unadvertendly removing the padding while doing a copy. Incidentally, h5py also do respect padding while doing copies, so I took this seriously and released a new PyTables version mainly for fixing this. You can