Skip to main content

pyd3js-timer

PyPI version Python versions License: ISC CI Security

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=100 in 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: setTimeout counting, this binding).

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.Timer instead of requestAnimationFrame / 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 setTimeout or assert this === undefined are not portable; see package_tests/test_upstream_timer.py and pytest skip 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyd3js_timer-0.1.0.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyd3js_timer-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

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

Hashes for pyd3js_timer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2b13955816b635d81611aac9840cbede8d9c28594827e20927423eb97b33f692
MD5 816385039449f65174e2906fc6e03ee9
BLAKE2b-256 8a9ed5e78a33b5ce78d561e0d71cd86cfc284242e736043c7455a6c6bf1ab2cc

See more details on using hashes here.

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

Hashes for pyd3js_timer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc82dae4e12708921f667a9237ebb299f8408e25fc91f5bf8f6cacf71a63e91f
MD5 161ef91264035f4075b36afc16c93944
BLAKE2b-256 64e8e692a747ed4dcb3177ec88116f21d42aa2a4b5a612cc3441a2bcc7fcae7a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page