Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Adds a "duplicate()" method on instances and fields #4294

Merged
merged 6 commits into from
May 27, 2020

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented May 27, 2020

Closes #4270.

This new method should be used in place of copy.deepcopy(). It can be overridden on certain fields to avoid making deep copies of certain attributes when deep copying is unnecessary or not possible.


Note: I was lazy and haven't added tests yet, but I'll do so before merging if ya'll agree with this approach.

@epwalsh epwalsh requested review from dirkgr and matt-gardner May 27, 2020 01:11
Copy link
Contributor

@matt-gardner matt-gardner left a comment

Choose a reason for hiding this comment

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

LGTM! Is there anything in the models repo that needs a similar change?

@epwalsh
Copy link
Member Author

epwalsh commented May 27, 2020

LGTM! Is there anything in the models repo that needs a similar change?

There is, I'll follow up with a PR for that.

@epwalsh epwalsh merged commit 79999ec into allenai:master May 27, 2020
@epwalsh epwalsh deleted the text-field-deep-copy branch May 27, 2020 15:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

deepcopy(instance) fails when using mismatched indexer.
2 participants