Implement Sequence and Mapping ABC Methods#52
Open
greateggsgreg wants to merge 1 commit intodaggaz:masterfrom
Open
Implement Sequence and Mapping ABC Methods#52greateggsgreg wants to merge 1 commit intodaggaz:masterfrom
greateggsgreg wants to merge 1 commit intodaggaz:masterfrom
Conversation
* Still need __len__ and __contains__ for transient list * Still need __ne__ for transient object
Owner
|
Hmm, interesting point on transient Maybe a new section in the docs with the exception linking to there? |
daggaz
reviewed
Jul 19, 2023
| return f"<{type(self).__name__}: {repr(self._data)}, {'STREAMING' if self.streaming else 'DONE'}>" | ||
|
|
||
| def __contains__(self, item): | ||
| self.read_all() |
Owner
There was a problem hiding this comment.
This could be implemented so that, if item is near the start, you don't have to read the whole thing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a companion to #50, since
issubclass()andisinstance()should imply that all of the ABC's methods are implemented.With the exception of
index()and__contains__(), the methods added to the persistent classes require reading the entire object anyway, so I just useself.read_all(). As I was posting this, I realized that__contains__()can be chained, not requiring the entire object to be read. I will modify that method when I revisit this.The methods added to the transient classes follow the pattern of using as little memory as possible, but in the case of
__reversed__(), I didn't see a way to avoid having the entire object in memory at first.The
index()method is mostly implemented in the list base class, with the child methods simply handling the offset math.I do have tests, but they need refactoring before I push them. I will be out of town until next Monday, but I wanted to push what I had to see if you had any initial feedback.