Skip to content

Structured dtype cleanup #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 23, 2011
Merged

Structured dtype cleanup #94

merged 11 commits into from
Jun 23, 2011

Conversation

mwiebe
Copy link
Member

@mwiebe mwiebe commented Jun 22, 2011

This set of patches cleans up structured dtypes. In particular:

Mark Wiebe added 6 commits June 21, 2011 13:07
This includes preserving the 'align=True' parameter through the
new NPY_ALIGNED_STRUCT dtype flag. The code now detects whether
the list version of structured dtype construction would match
the data layout, to choose between list and struct based construction.
The 'struct'-based repr adds this parameter, as the general way to
be able to reconstruct the dtype.
numpy#1790)

In the case referenced in ticket numpy#1790, the itemsize was set before
the padded size was calculated, so the intent was clearly that it
should have been aligned.
This will require validation that object dtypes don't overlap with
other fields in a follow-on commit.
/* The alignment is always a power of 2, so this works */
totalsize = (totalsize + maxalign - 1) & (-maxalign);
}

new = PyArray_DescrNewFromType(PyArray_VOID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filler ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is specifically the bugfix for #1790. That code (well, functionally equivalent code) was already there, just after assigning totalsize to new->elsize.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the filler is gone, you just provide enough aligned space for the item?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe there never was any filler, just the illusion of filler created during the repr call.

@charris
Copy link
Member

charris commented Jun 22, 2011

Looks good as far as I am able to judge.

@mwiebe
Copy link
Member Author

mwiebe commented Jun 22, 2011

I've added some more commits:

  • Object field overlap validation
  • Make sure nested struct dtypes obey alignment
  • Put the 'itemsize' parameter in the dict constructor instead of as a dtype parameter
  • Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants