Repository navigation
Manchester | 26-SDC-Jun | Fithi Teklom | Sprint 2 | Linked Link in Python - #260
Open
Fithi-Teklom wants to merge 2 commits into
Open
Fithi-Teklom wants to merge 2 commits into
Fithi-Teklom wants to merge 2 commits into
Conversation
cjyuan
reviewed
Oct 16, 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
+43
to
+52
| # If there's only one carriage, the train becomes empty | ||
| if self.head == self.tail: | ||
| self.head = None | ||
| self.tail = None | ||
| else: | ||
| # Move the tail backwards by one carriage | ||
| self.tail = self.tail.previous | ||
|
|
||
| # The new last carriage has no carriage after it | ||
| self.tail.next = None |
There was a problem hiding this comment.
Could consider delegating the node removing task to remove() -- less code to maintain.
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.
Thank you for your feedback @cjyuan . So I have
-Added type hints.
-Reused remove() inside pop_tail().
-Added slots to reduce node memory overhead.
cjyuan
reviewed
Oct 17, 2026
|
|
||
| def push_head(self, value): | ||
| # Make a new carriage | ||
| class Node(Generic[T]): |
There was a problem hiding this comment.
Good use of generics! Nice!
Note: I think since Python 3.12, there is a slightly simpler syntax to use generics.
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.
Self checklist
Task code
CYF-1180
Changelist
Implement doubly linked list operations.