pyd3js-timer
Python port of d3-timer.
Tracked version: see upstream_lock.json.
What is d3-timer?
d3-timer is D3’s low-level timer queue: a monotonic now(), repeating timer work, one-shot timeout, repeating interval, and a synchronous timerFlush() to run all due callbacks. It is used by d3-transition and other modules for efficient, coalesced scheduling (frames vs long sleeps).
What you get
- Upstream export parity for the pinned
d3-timer@3.0.1(see API inventory). - 100% line coverage for
pyd3js_timer(enforced with--cov-fail-under=100in this package’s pytest config and in CI). - Pytest ports of the upstream Mocha suite under
package_tests/test_upstream_*.py(a few Node-only cases are skipped with reasons:setTimeoutcounting,thisbinding).
Install
From PyPI:
pip install pyd3js-timer
This repo is a uv workspace monorepo. For local development:
uv sync --group dev
Dependencies
The published package has no third-party Python dependencies (Python standard library only, including threading).
Usage
from pyd3js_timer import now, timer, timer_flush, timeout, interval, Timer
t = timer(lambda elapsed: None)
t.stop()
timeout(lambda elapsed: print("once"), 100)
i = interval(lambda elapsed: print("tick"), 50)
i.stop()
timer_flush() # run any due callbacks synchronously
Stability & host differences
- Threading: the port uses
threading.Timerinstead ofrequestAnimationFrame/setTimeout. Real-time jitter and the exact “frame” schedule differ from a browser; semantics follow d3-timer’s logic (frame vs long wake,timerFlush, poke/skew). - Skipped upstream tests: tests that monkey-patch global
setTimeoutor assertthis === undefinedare not portable; seepackage_tests/test_upstream_timer.pyandpytestskip reasons.
Testing
Run the package tests:
uv run pytest packages/pyd3js-timer/package_tests
Or from packages/pyd3js-timer (uses this package’s pyproject coverage gate):
cd packages/pyd3js-timer && uv run pytest
Coverage (Python)
uv run pytest packages/pyd3js-timer/package_tests -q --cov=pyd3js_timer --cov-report=term-missing --cov-fail-under=100
Before publishing (maintainers)
Verify release readiness from the repo root:
uv run ruff check packages/pyd3js-timer
uv run ty check packages/pyd3js-timer/src
uv run pytest packages/pyd3js-timer/package_tests -q --cov=pyd3js_timer --cov-fail-under=100
uv build packages/pyd3js-timer
uv run twine check dist/pyd3js_timer-*.whl dist/pyd3js_timer-*.tar.gz
Confirm version in packages/pyd3js-timer/pyproject.toml matches pyd3js_timer.__version__ and the heading for 0.1.0 in docs/CHANGELOG.md.
Documentation
- User guide:
docs/USER_GUIDE.md - Changelog:
docs/CHANGELOG.md - Upstream API inventory:
docs/UPSTREAM_API.md - Updating upstream:
docs/UPSTREAM_UPDATE.md - Design notes:
docs/ROADMAP.md
Metadata
Release files for pyd3js-timer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyd3js_timer-0.1.0.tar.gz | 45.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyd3js_timer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.8 kB
Release files / pyd3js_timer-0.1.0.tar.gz
| Download URL | pyd3js_timer-0.1.0.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b13955816b635d81611aac9840cbede8d9c28594827e20927423eb97b33f692
|
|
BLAKE2b-256 checksum How to use checksums |
8a9ed5e78a33b5ce78d561e0d71cd86cfc284242e736043c7455a6c6bf1ab2cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / pyd3js_timer-0.1.0-py3-none-any.whl
| Download URL | pyd3js_timer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc82dae4e12708921f667a9237ebb299f8408e25fc91f5bf8f6cacf71a63e91f
|
|
BLAKE2b-256 checksum How to use checksums |
64e8e692a747ed4dcb3177ec88116f21d42aa2a4b5a612cc3441a2bcc7fcae7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|