[issue46169] Same-moment datetimes with different ZoneInfo timezones are not considered ==
New submission from Huon Wilson : The documentation suggests that two datetimes that represent the same moment should compare equal, even if they have different timezones: "If both comparands are aware and have different tzinfo attributes, the comparands are first adjusted by subtracting their UTC offsets (obtained from self.utcoffset())." (below https://docs.python.org/3/library/datetime.html#datetime.datetime.fold) This doesn't seem to be true for == with ZoneInfo timezones, even though it is true for <= and >=, and -, meaning these seem to violate mathematical laws/expectations: from zoneinfo import ZoneInfo from datetime import datetime, timezone dt_utc = datetime(2020, 11, 1, 8, tzinfo=timezone.utc) dt_local = dt_utc.astimezone(ZoneInfo("America/Los_Angeles")) print(f"{dt_local == dt_utc = }") print(f"{dt_local <= dt_utc = }") print(f"{dt_local >= dt_utc = }") print(f"{dt_local - dt_utc = }") Output: dt_local == dt_utc = False dt_local <= dt_utc = True dt_local >= dt_utc = True dt_local - dt_utc = datetime.timedelta(0) Tested with: - macOS 11.4; Python 3.9.7, 3.10.1, 3.11.0a3 - Linux; via docker image python:3.9.7 Full test including comparisons to python-dateutil (same behaviour as ZoneInfo) and pytz (== gives True as expected) is attached. Comparing timestamps for exact equality is potentially unusual, but we use it extensively in tests for some time-handling functions. -- components: Library (Lib) files: tz.py messages: 409113 nosy: huonw priority: normal severity: normal status: open title: Same-moment datetimes with different ZoneInfo timezones are not considered == type: behavior versions: Python 3.10, Python 3.11, Python 3.9 Added file: https://bugs.python.org/file50516/tz.py ___ Python tracker <https://bugs.python.org/issue46169> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40630] tracemalloc: allow resetting peak memory metric without touching other traces
New submission from Huon Wilson : Per https://mail.python.org/archives/list/python-id...@python.org/thread/QDWI37A4TJXOYUKULGPY2GKD7IG2JNDC/ , it would be helpful to have a function that resets the peak memory usage of the tracemalloc module, without changing all the traces. This allows for recording the peak memory usage of a specific region of code, rather than only the peak since the last tracemalloc.start() or tracemalloc.clear_traces() call. -- components: Library (Lib) messages: 368916 nosy: huonw, vstinner priority: normal severity: normal status: open title: tracemalloc: allow resetting peak memory metric without touching other traces type: enhancement versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue40630> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40630] tracemalloc: allow resetting peak memory metric without touching other traces
Change by Huon Wilson : -- keywords: +patch pull_requests: +19409 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20102 ___ Python tracker <https://bugs.python.org/issue40630> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40630] tracemalloc: allow resetting peak memory metric without touching other traces
Change by Huon Wilson : -- pull_requests: +19790 pull_request: https://github.com/python/cpython/pull/20545 ___ Python tracker <https://bugs.python.org/issue40630> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40630] tracemalloc: allow resetting peak memory metric without touching other traces
Change by Huon Wilson : -- pull_requests: +19791 pull_request: https://github.com/python/cpython/pull/20546 ___ Python tracker <https://bugs.python.org/issue40630> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com