Skip to content

When writing a table, make only a shallow copy#11919

Merged
taldcroft merged 3 commits intoastropy:mainfrom
mhvk:table-write-avoid-full-copy
Jul 6, 2021
Merged

When writing a table, make only a shallow copy#11919
taldcroft merged 3 commits intoastropy:mainfrom
mhvk:table-write-avoid-full-copy

Conversation

@mhvk
Copy link
Copy Markdown
Contributor

@mhvk mhvk commented Jul 2, 2021

I looked into the errors that occur when writing a table without first making a copy. It is clear the problem is that the writer can set info properties such as format - obviously, these should not propagate back to the input table. A copy avoids this, but it is not necessary for this to be a deep copy.

Fixes #7605

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see "When to rebase and squash commits".
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the Extra CI label.
  • Is a change log needed? If yes, did the change log check pass? If no, add the no-changelog-entry-needed label.
  • Is a milestone set? Milestone must be set but astropy-bot check might be missing; do not let the green checkmark fool you.
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate backport-X.Y.x label(s) before merge.

@mhvk mhvk added this to the v5.0 milestone Jul 2, 2021
@mhvk mhvk requested a review from taldcroft July 2, 2021 15:20
@mhvk

This comment has been minimized.

@mhvk
Copy link
Copy Markdown
Contributor Author

mhvk commented Jul 2, 2021

Actually, the errors in .to_pandas are not related - also seen in #11916. And already an issue raised by @pllim - see #11918

@taldcroft
Copy link
Copy Markdown
Member

I'm pretty sure the test fail will go away after rebasing on main after #11921. This looks fine otherwise.

@taldcroft
Copy link
Copy Markdown
Member

taldcroft commented Jul 6, 2021

I think a changelog entry is warranted, both to highlight a performance improvement and in the very unlikely event that this causes something unexpected in a custom writer.

@mhvk mhvk force-pushed the table-write-avoid-full-copy branch from 3f49fae to 645c1f3 Compare July 6, 2021 13:16
@mhvk
Copy link
Copy Markdown
Contributor Author

mhvk commented Jul 6, 2021

OK, thanks! I added a changelog entry and rebased; good to check that everything passes!

Copy link
Copy Markdown
Member

@taldcroft taldcroft left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@taldcroft taldcroft merged commit ce3413c into astropy:main Jul 6, 2021
@mhvk mhvk deleted the table-write-avoid-full-copy branch July 6, 2021 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary table copy in ascii.write

2 participants