Python port of d3-timer
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyd3js_timer-0.1.0.tar.gz.
File metadata
- Download URL: pyd3js_timer-0.1.0.tar.gz
- Upload date:
- Size: 45.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b13955816b635d81611aac9840cbede8d9c28594827e20927423eb97b33f692
|
|
| MD5 |
816385039449f65174e2906fc6e03ee9
|
|
| BLAKE2b-256 |
8a9ed5e78a33b5ce78d561e0d71cd86cfc284242e736043c7455a6c6bf1ab2cc
|
File details
Details for the file pyd3js_timer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyd3js_timer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc82dae4e12708921f667a9237ebb299f8408e25fc91f5bf8f6cacf71a63e91f
|
|
| MD5 |
161ef91264035f4075b36afc16c93944
|
|
| BLAKE2b-256 |
64e8e692a747ed4dcb3177ec88116f21d42aa2a4b5a612cc3441a2bcc7fcae7a
|