GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||
GeezerVison is showing github.com — Use `PyObject_CallMethodOneArg` in datetime `call_tzinfo_method` · Issue #151059 · python/cpython Closed Labels extension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement DescriptionFeature or enhancementProposal:The offset = PyObject_CallMethod(tzinfo, name, "O", tzinfoarg); On every call this parses the BenchmarksWall-clock, PGO+LTO build
Benchmark script"""Microbenchmark for datetime call_tzinfo_method (gh-150942).""" import datetime as dt import time from datetime import timezone from zoneinfo import ZoneInfo ny = ZoneInfo("America/New_York") utc_dt = dt.datetime(2024, 6, 7, 16, 30, tzinfo=timezone.utc) ny_dt = dt.datetime(2024, 6, 7, 12, 30, tzinfo=ny) def bench(fn, N=1_000_000, repeat=7): best = float("inf") for _ in range(repeat): start = time.perf_counter() for _ in range(N): fn() best = min(best, (time.perf_counter() - start) / N * 1e9) return best CASES = { "astimezone() UTC->local": lambda: utc_dt.astimezone(ny), "timestamp()": lambda: ny_dt.timestamp(), "isoformat()": lambda: ny_dt.isoformat(), "utcoffset()": lambda: ny_dt.utcoffset(), "now().isoformat()": lambda: dt.datetime.now().isoformat(), # naive: control "tzname() [control]": lambda: ny_dt.tzname(), } print(f"{'operation':<26}{'ns/op':>10}") print("-" * 36) for name, fn in CASES.items(): print(f"{name:<26}{bench(fn):>9.1f}") Has this already been discussed elsewhere?No response given Links to previous discussion of this feature:No response Linked PRsActivity
MetadataMetadataAssigneesLabelsextension-modulesC modules in the Modules dirC modules in the Modules dirperformancePerformance or resource usagePerformance or resource usagetype-featureA feature request or enhancementA feature request or enhancement Projects
MilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||||||||||||||
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |