lazy_segment_tree.py-static-type-checking#2303
lazy_segment_tree.py-static-type-checking#2303kanthuc wants to merge 12 commits intoTheAlgorithms:masterfrom kanthuc:master
Conversation
pull from master
|
Hey @kanthuc, TravisCI finished with status TravisBuddy Request Identifier: c686fa70-dd23-11ea-b6e2-493429cddfc3 |
You can rename |
|
Hey @kanthuc, TravisCI finished with status TravisBuddy Request Identifier: 7f59b910-e0f4-11ea-a6dd-d374b9ca78b0 |
|
|
||
| class SegmentTree: | ||
| def __init__(self, N): | ||
| def __init__(self, N: int) -> None: |
There was a problem hiding this comment.
Why is N in uppercase? Uppercase is reserved for constants in Python naming. Could we come up with a more self-documenting name than a single character?
| def __init__(self, N: int) -> None: | ||
| self.N = N | ||
| self.st = [ | ||
| self.st: List[int] = [ |
There was a problem hiding this comment.
What is st? Why does the reader have to guess? Can't we come up with a more self-documenting name?
| self.lazy: List[int] = [ | ||
| 0 for i in range(0, 4 * N) | ||
| ] # create array to store lazy update | ||
| self.flag: List[int] = [0 for i in range(0, 4 * N)] # flag for lazy update |
There was a problem hiding this comment.
What exactly are we flagging with this variable? This type hint is not required. The typing system can already figure out that a list comprehension creates a list and that 0 is an int. This type hint just creates cognitive clutter for the reader.
There was a problem hiding this comment.
Sorry, the changes I made in this pr were already included in pr#2329 which was merged recently, so I closed this pr. I'll make these changes separately and send out a new pr. Thanks
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}.