Implement Sequence and Mapping ABC Methods #52
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.