Message362934
A problem of having this bit of state in paths is that it violates assumptions based on immutability/hashability, e.g. with
from pathlib import Path
p = Path("foo")
q = Path("foo")
with p: pass
unique_paths = {p, q}
print(len(unique_paths)) # == 1, as p == q
for path in unique_paths:
print(path.resolve()) # Fails if the path is closed.
The last line fails with `unique_paths = {p, q}` as p has been closed (and apparently sets keep the first element when multiple "equal" elements are passed in), but not with `unique_paths = {q, p}`.
It would also prevent optimizations based on immutability as proposed in https://bugs.python.org/issue39783. |
|
Date |
User |
Action |
Args |
2020-02-28 22:53:44 | Antony.Lee | set | recipients:
+ Antony.Lee, brett.cannon, pitrou, barneygale |
2020-02-28 22:53:43 | Antony.Lee | set | messageid: <1582930423.99.0.883398728645.issue39682@roundup.psfhosted.org> |
2020-02-28 22:53:43 | Antony.Lee | link | issue39682 messages |
2020-02-28 22:53:43 | Antony.Lee | create | |
|