Skip to content
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

make slicing of Sequence more efficient #103

Open
DaniBodor opened this issue Sep 15, 2023 · 2 comments
Open

make slicing of Sequence more efficient #103

DaniBodor opened this issue Sep 15, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@DaniBodor
Copy link
Member

I noticed that when slicing a Sequence, a we first create a deepcopy of the original object, which we then whittle down to the size indicated. This seems inefficient, especially if the original Sequence is much larger than the slice we want.

Instead we could create a new "empty" Sequence, into which we then copy (or deepcopy?) the relevant slices from the old Sequence.

Does this make sense @psomhorst ?

@DaniBodor DaniBodor changed the title making slicing of Sequence more efficient make slicing of Sequence more efficient Sep 15, 2023
@psomhorst
Copy link
Contributor

Yes, this makes a lot of sense.

I'm wondering what the best approach is. I defaulted to deepcopy to make sure the Framesets, Events, etc. were copied, instead of referencing to the same Framesets, Events, etc. as the original. Maybe we can create an implementation of Sequence.__copy__() (see bottom paragraph of https://docs.python.org/3.11/library/copy.html#copy.deepcopy) to create a copy of Sequence that (deep)copies all Events, Phases, etc., but creates new Framesets using sliced data instead of copying the entire Frameset including data.

@DaniBodor
Copy link
Member Author

Also, see this discussion on ensuring that copy.deepcopy(sequence) and sequence.deepcopy() are equivalent.

@DaniBodor DaniBodor added the enhancement New feature or request label Sep 19, 2023
@psomhorst psomhorst added this to the Next release: 1.5.0 milestone Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants