| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import sys | ||
| from _tracemalloc import * | ||
| from typing import Optional, Sequence, Union, overload | ||
| from typing import Any, Optional, Sequence, Union, overload | ||
| from typing_extensions import SupportsIndex | ||
|
|
||
| def get_object_traceback(obj: object) -> Traceback | None: ... | ||
| Expand Down Expand Up | @@ -41,6 +41,15 @@ class Frame: | |
| filename: str | ||
| lineno: int | ||
| def __init__(self, frame: _FrameTupleT) -> None: ... | ||
| def __lt__(self, other: Frame) -> bool: ... | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityConfirmed that __lt__ for some reason does not have the NotImplemented trick.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt's because it's functools.total_ordering that uses the NotImplemented trick, and __lt__ is the only method that's actually defined on the class (all the other methods are autogenerated using @functools.total_ordering).
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis recent change is why I used the sys.version_info guards, FWIW: python/cpython#30818
Sorry, something went wrong.
All reactions
|
||
| if sys.version_info >= (3, 11): | ||
| def __gt__(self, other: Frame) -> bool: ... | ||
| def __ge__(self, other: Frame) -> bool: ... | ||
| def __le__(self, other: Frame) -> bool: ... | ||
| else: | ||
| def __gt__(self, other: Frame, NotImplemented: Any = ...) -> bool: ... | ||
| def __ge__(self, other: Frame, NotImplemented: Any = ...) -> bool: ... | ||
| def __le__(self, other: Frame, NotImplemented: Any = ...) -> bool: ... | ||
|
|
||
| if sys.version_info >= (3, 9): | ||
| _TraceTupleT = Union[tuple[int, int, Sequence[_FrameTupleT], Optional[int]], tuple[int, int, Sequence[_FrameTupleT]]] | ||
| Expand Down Expand Up | @@ -69,6 +78,15 @@ class Traceback(Sequence[Frame]): | |
| @overload | ||
| def __getitem__(self, s: slice) -> Sequence[Frame]: ... | ||
| def __len__(self) -> int: ... | ||
| def __lt__(self, other: Traceback) -> bool: ... | ||
| if sys.version_info >= (3, 11): | ||
| def __gt__(self, other: Traceback) -> bool: ... | ||
| def __ge__(self, other: Traceback) -> bool: ... | ||
| def __le__(self, other: Traceback) -> bool: ... | ||
| else: | ||
| def __gt__(self, other: Traceback, NotImplemented: Any = ...) -> bool: ... | ||
| def __ge__(self, other: Traceback, NotImplemented: Any = ...) -> bool: ... | ||
| def __le__(self, other: Traceback, NotImplemented: Any = ...) -> bool: ... | ||
|
|
||
| class Snapshot: | ||
| def __init__(self, traces: Sequence[_TraceTupleT], traceback_limit: int) -> None: ... | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think we should use Counter[Any] here. It doesn't work with all Counters, only with Counters of a type that's comparable to our type. That's something we can't express in the current type system, so we should use Any.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat am I missing? :)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityAh right, the type parameter is the keys, but it compares the values, which are always ints.
This does make for some fun behavior:
In [16]: Counter((1, 2, 3)) < Counter('abcde') Out[16]: False In [17]: Counter('abcde') < Counter((1, 2, 3)) Out[17]: FalseSorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCounters are sort of halfway between dicts and sets, and the comparison methods come from the set-like side of their personality, so it does sort of make sense if you squint at it from the right angle.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.