Repository navigation
London | 26-Jul-SDC | Roman Sanaye | Sprint 2 | Implement a linked list in Python - #242
Open
RomanSanaye wants to merge 3 commits into
Open
RomanSanaye wants to merge 3 commits into
RomanSanaye wants to merge 3 commits into
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
+3
to
+7
| 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?
Comment on lines
+44
to
+51
| if self.head == self.tail: | ||
| self.head = None | ||
| self.tail = None | ||
| else: | ||
| # Move the tail pointer back to the previous node | ||
| self.tail = self.tail.previous | ||
| # Cut off the old tail by clearing its 'next' reference | ||
| self.tail.next = None |
There was a problem hiding this comment.
Could consider delegating the node removing task to remove() -- less code to maintain.
Author
|
Hi @cjyuan ,
Ready for re-review! |
cjyuan
reviewed
Oct 15, 2026
| self.next = None | ||
| self.previous = None | ||
| __slots__ = ("value", "next", "previous") | ||
| def __init__(self, value: Any)-> None: |
There was a problem hiding this comment.
Additional reading: Use AI to explore
- Specifying type as
objectvs asAny - Python 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
linked_list.pyusingNodeandLinkedListclasses.push_head: Adds an element to the start and returns the node as a direct handle.pop_tail: Removes an element from the back using thetailpointer instantly.remove: Removes a specific node in constant time using its handle.linked_list_test.py.Questions
No questions at the moment—all unit tests passed successfully!