{"id":9812,"library":"hightime","title":"Hightime Python API","description":"Hightime is a Python library from National Instruments designed for representing and manipulating durations and time intervals with high precision. It provides classes like `Interval` and `Unit` to define time quantities, enabling arithmetic operations and conversions between different units. The current stable version is 1.0.0, which includes significant improvements in Python version compatibility and type hinting. Releases appear to be driven by feature additions and Python version updates rather than a fixed schedule.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/ni/hightime","tags":["time","duration","precision","intervals","measurements"],"install":[{"cmd":"pip install hightime","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"Interval","correct":"from hightime import Interval"},{"symbol":"Unit","correct":"from hightime import Unit"},{"note":"Used for representing discrete states in time (e.g., ON/OFF), less common for basic duration tasks.","symbol":"State","correct":"from hightime import State"}],"quickstart":{"code":"from hightime import Interval, Unit\n\n# Create an interval of 5.5 seconds\ninterval_a = Interval(5.5, Unit.SECONDS)\nprint(f\"Interval A: {interval_a}\")\n\n# Create another interval of 1000 milliseconds\ninterval_b = Interval(1000, Unit.MILLISECONDS)\nprint(f\"Interval B: {interval_b}\")\n\n# Perform arithmetic operations\ninterval_sum = interval_a + interval_b\nprint(f\"Sum: {interval_sum}\")  # Should be 6.5 seconds\n\n# Convert an interval to different units\nmilliseconds = interval_sum.in_units(Unit.MILLISECONDS)\nprint(f\"Sum in milliseconds: {milliseconds} ms\")\n\n# Access total seconds with higher precision\ntotal_seconds_precise = interval_sum.precision_total_seconds\nprint(f\"Sum in precise total seconds: {total_seconds_precise} s\")","lang":"python","description":"This quickstart demonstrates how to create `Interval` objects, perform basic arithmetic, and convert intervals between different `Unit` types. It also shows how to retrieve precise total seconds."},"warnings":[{"fix":"Upgrade your Python environment to 3.9 or newer (e.g., Python 3.9-3.13 are supported by v1.0.0).","message":"Version 1.0.0 dropped support for Python 3.7 and 3.8. Users on these older Python versions must upgrade their Python environment or use an older version of the `hightime` library.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade to `hightime` version 1.0.0 or newer to resolve the infinite recursion issue on PyPy.","message":"When running on PyPy, versions of `hightime` prior to 1.0.0 could experience infinite recursion if `copy` or `pickle` operations were performed on `hightime` objects.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Ensure you are using `hightime` version 1.0.0 or newer. When comparing `Interval` objects, ensure the other operand is also a `hightime.Interval` or a type explicitly supported for comparison.","message":"Older versions of `hightime` (pre-1.0.0) had issues with comparisons against 'unknown types', potentially leading to unexpected `TypeError` or incorrect comparison results.","severity":"gotcha","affected_versions":"<1.0.0"},{"fix":"Use `interval.precision_total_seconds` (available from v0.2.2) for the most accurate representation of an interval's total duration in seconds.","message":"For maximum precision when getting the total duration in seconds, use `interval.precision_total_seconds`. The `total_seconds` property might truncate precision in some cases.","severity":"gotcha","affected_versions":"<0.2.2"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install hightime` to install the library.","cause":"The `hightime` library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'hightime'"},{"fix":"Convert `datetime.timedelta` to a `hightime.Interval` first. For example: `hightime_interval + Interval(timedelta_obj.total_seconds(), Unit.SECONDS)`.","cause":"You are attempting to directly add a `hightime.Interval` object with a standard library `datetime.timedelta` object, which `hightime` does not implicitly support.","error":"TypeError: unsupported operand type(s) for +: 'hightime.Interval' and 'datetime.timedelta'"},{"fix":"Upgrade your Python environment to version 3.9 or higher (e.g., 3.9, 3.10, 3.11, 3.12, 3.13) to meet the library's requirements.","cause":"You are trying to install or run `hightime` (especially v1.0.0 or later) on an unsupported Python version (e.g., Python 3.7 or 3.8).","error":"ERROR: Package 'hightime' requires a different Python version: 3.x.y (current is 3.a.b)"}]}