Repository navigation
Conversation
cjyuan
reviewed
Oct 13, 2026
cjyuan
left a comment
There was a problem hiding this comment.
Could consider adding type hints to each method to clearly specify the types of its parameters and return value.
Comment on lines
+2
to
+6
| class Node: | ||
| def __init__(self, value): | ||
| self.value = value | ||
| self.next = None | ||
| self.previous = None |
There was a problem hiding this comment.
May I suggest exploring the use of __slots__ to reduce memory usage?
Author
There was a problem hiding this comment.
Thanks for the suggestion! I added type hints and used slots for the node attributes to reduce memory usage. @cjyuan
Comment on lines
+31
to
+42
| old_tail = self.tail | ||
| value = old_tail.value | ||
|
|
||
| if self.head is self.tail: | ||
| self.head = None | ||
| self.tail = None | ||
| else: | ||
| self.tail = old_tail.previous | ||
| self.tail.next = None | ||
|
|
||
| old_tail.next = None | ||
| old_tail.previous = None |
There was a problem hiding this comment.
Why not delegate the node removing task to remove()? Less code to maintain.
Author
There was a problem hiding this comment.
Good suggestion. I updated pop_tail() to call remove(old_tail) so the unlinking logic is kept in one place. @cjyuan
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.
Learners, PR Template
Self checklist
Task code
CYF-1180
Changelist
Implemented a doubly linked list in Python with O(1) operations for adding elements at the head, removing elements from the tail, and removing specific elements using node handles.