Interval bugs often hide at a shared endpoint. Two jobs occupy [2, 5) and [5, 8). They do not overlap, yet their combined coverage is one uninterrupted span. A function that uses the same comparison for both questions can produce a believable answer while implementing the wrong policy. The problem becomes harder when records arrive out of order, a short interval sits inside a longer one, or an occupied span extends beyond the window you are examining.
This guide builds a small Python interval library and shows how to use DeepSeek as a reviewer of its contract, examples and tests. The library normalizes coverage, finds intersections and returns gaps inside a finite horizon. The examples use integer coordinates, so the same reasoning can apply to byte offsets, numbered work slots or positions along a sequence. Calendar parsing, real-time booking and time-zone conversion are deliberately outside the implementation.
The practical recommendation is to write down endpoint rules before requesting code, then compare the implementation with an independently constructed coverage oracle. A polished explanation does not establish that an endpoint comparison is correct. A runnable counterexample, an explicit expected result and a reproducible test give you something firmer to review. All code and diagrams in this guide are original. The supplied DeepSeek prompts are templates; no DeepSeek model or API execution was performed for this article.
Our property-based testing guide uses interval merging to explain Hypothesis and shrinking. This tutorial extends that foundation to common coverage between two collections and free gaps inside a horizon. It also examines the source information that merging discards. The implementation and verification lab here are separate, standard-library-only examples with their own stricter input contract.
Start with a coverage contract
Our input object represents one nonempty half-open interval: the start is included and the end is excluded. Both endpoints must be exact built-in Python integers, and the start must be smaller than the end. Negative coordinates are valid. Empty and reversed intervals raise an error rather than disappearing silently. That choice makes malformed input visible at the boundary where the object is constructed.
There are four public operations. overlaps answers whether two intervals share positive-length coverage. normalize returns the union of a finite collection, sorted by position and merged wherever spans overlap or touch. intersection returns coverage that appears in both collections. gaps returns everything inside one horizon that is absent from the busy collection. Every collection result is a tuple of intervals.
The normalized representation has a stronger property than simply being sorted. Each output interval ends strictly before the next one starts. Adjacent spans are merged, so a remaining separation always represents a genuine uncovered gap. Duplicates do not change coverage. Input order does not change the result. Normalizing an already normalized result gives the same value. These rules make expected outputs precise enough for exact equality assertions.
The contract describes coverage, not event history. A normalized span cannot tell you how many source records contributed to it, which customer owns it or which record should be removed later. Keep those records separately. The functions also assume finite iterables supplied by trusted application code. They copy and sort input; they are neither an infinite-stream processor nor a protective sandbox for hostile Python objects.
Before adapting the lab, choose a unit and write it beside the data model. An endpoint of 90 might mean bytes, seconds, frames or slots. Mixing units can create results that satisfy every structural invariant while remaining meaningless. Unit conversion belongs at a clearly tested boundary before these operations, with an explicit policy for any rounding or loss of precision.
Distinguish touching from overlapping
For an interval [a, b), membership means that a coordinate is at least a and strictly less than b. Its length is b - a. There is no extra unit added at the end. This convention fits the familiar stop-exclusive behavior of Python ranges and avoids assigning a shared boundary to both adjacent spans. The library works with endpoints rather than expanding an interval into all of its positions.
Consider [2, 5) and [5, 8). The first interval excludes 5; the second includes it. Their intersection is empty. Nevertheless, their union is exactly [2, 8), because there is no uncovered position between them. Treating them as one span is useful when summarizing occupied coverage. Treating them as a conflicting pair would be wrong under this contract.
The overlap condition therefore uses a strict comparison: the later start must be smaller than the earlier end. The merge condition permits equality: the next start may be equal to the current end. Those comparisons answer different questions. Give them different test cases instead of asking a reviewer whether one vague “overlap algorithm” looks correct.
A contrasting pair is [2, 6) and [5, 8). These share [5, 6), so the overlap predicate returns true. Their union remains [2, 8). Looking only at the merged output would miss the distinction between overlap and adjacency. This is why the lab tests the predicate, intersection and normalization separately, even when they process similar input.

Do not translate inclusive source intervals by casually adding one to the end unless the domain is genuinely discrete and one is the correct successor step. Closed integer indices can often be converted that way. Arbitrary real-valued measurements cannot. Likewise, a point event has zero duration and needs its own representation here; converting it into an occupied interval changes its meaning.
Implement validation and the three collection operations
The implementation below keeps the public surface small enough to inspect in one sitting. The interval object validates its own endpoints. Collection functions reject values that are not exact Interval instances. This intentionally narrow policy excludes subclasses and automatic coercion. If your application accepts other numeric types or external record shapes, add a separate conversion layer with its own error messages and tests.
Python type annotations describe the intended shape but do not perform these runtime checks for us. The dataclass generates routine methods, while __post_init__ enforces the endpoint contract. The frozen setting prevents ordinary field reassignment. It is a convenience for maintaining values, not a security barrier against code deliberately bypassing normal attribute access. The guide on Python dataclass validation and ownership explores that distinction in more detail.
Boolean values deserve a deliberate decision because Python treats them as a subtype of integers. Accepting True as a coordinate is usually surprising for this interface. Exact-type checks make the rejection visible and consistent. The code also avoids floating-point tolerance rules entirely. It does not quietly round values, compare approximate endpoints or guess whether two nearly equal positions should touch.
"""Finite collections of nonempty integer half-open intervals.
Endpoints use exact built-in ints; bool and int subclasses are rejected.
Normalization merges touching spans. Results are tuples in increasing order.
No I/O, calendars, concurrency control, or record-identity preservation.
"""
from collections.abc import Iterable
from dataclasses import dataclass
@dataclass(frozen=True)
class Interval:
start: int
end: int
def __post_init__(self) -> None:
if type(self.start) is not int or type(self.end) is not int:
raise TypeError("endpoints must be exact integers")
if self.start >= self.end:
raise ValueError("an interval must have start < end")
def _require_interval(value: object) -> None:
if type(value) is not Interval:
raise TypeError("expected an Interval")
def overlaps(left: Interval, right: Interval) -> bool:
"""True only when the two spans have positive-length intersection."""
_require_interval(left)
_require_interval(right)
return max(left.start, right.start) < min(left.end, right.end)
def normalize(values: Iterable[Interval]) -> tuple[Interval, ...]:
"""Return sorted, disjoint spans, merging overlaps and adjacency."""
items = list(values)
for item in items:
_require_interval(item)
items.sort(key=lambda item: (item.start, item.end))
result: list[Interval] = []
for item in items:
if not result or item.start > result[-1].end:
result.append(item)
else:
previous = result[-1]
result[-1] = Interval(previous.start, max(previous.end, item.end))
return tuple(result)
def intersection(
left: Iterable[Interval], right: Iterable[Interval]
) -> tuple[Interval, ...]:
"""Return normalized coverage present in both finite collections."""
a, b = normalize(left), normalize(right)
i = j = 0
result: list[Interval] = []
while i < len(a) and j < len(b):
start = max(a[i].start, b[j].start)
end = min(a[i].end, b[j].end)
if start < end:
result.append(Interval(start, end))
if a[i].end < b[j].end:
i += 1
elif b[j].end < a[i].end:
j += 1
else:
i += 1
j += 1
return tuple(result)
def gaps(
horizon: Interval, busy: Iterable[Interval]
) -> tuple[Interval, ...]:
"""Return the normalized complement of busy inside one finite horizon."""
_require_interval(horizon)
clipped = intersection((horizon,), busy)
cursor = horizon.start
result: list[Interval] = []
for item in clipped:
if cursor < item.start:
result.append(Interval(cursor, item.start))
cursor = item.end
if cursor < horizon.end:
result.append(Interval(cursor, horizon.end))
return tuple(result)
The collection functions return tuple results and never sort the caller’s list in place. An iterator is consumed as input is copied, so the caller cannot expect to reuse an exhausted generator. If input iteration raises an exception, that exception propagates and the function returns no result. This is ordinary function failure behavior; it does not undo side effects that the input iterator itself may already have performed.
Why the normalization scan works
Normalization begins by collecting and validating the input, then sorting by the pair of endpoints. Sorting by the start places every candidate after intervals that begin earlier. Including the end in the key gives a deterministic order for equal starts, although the coverage result does not depend on which equal-start interval arrives first. The broader guide to stable keys and deterministic sorting is useful when your source records carry additional fields.
During the scan, the output contains completed spans followed by one current span. A new interval either begins beyond the current end, creating a real gap, or begins at or before that end and belongs to the same merged span. In the second case, the end becomes the larger of the two ends. The start stays fixed because sorting has already established the earliest start for that component.
The maximum matters. Suppose the current interval is [0, 12) and the next is [2, 4). Replacing the current end with 4 would erase valid coverage. A later [5, 7) could then appear separate even though both shorter intervals are inside the original one. This nested case is a better review example than a list containing only progressively extending spans.
The scan needs to compare only with its last output span. If the new interval starts after that span, all earlier completed spans also end before it. If it connects to the last span, updating that span cannot reach backward across an earlier gap because its start does not move. This local invariant explains the algorithm more clearly than a claim that the code is a standard pattern.
There is a policy choice hidden in the word “canonical.” Here we merge adjacency to give one representation for continuous coverage. Another application might preserve adjacent segments because they indicate different tariff bands or owners. That application requires a different contract and probably different data. Changing one comparison in this library without changing the expected outputs would make the documentation and implementation disagree.
Intersect two normalized collections with two cursors
Intersection first normalizes each collection. That removes internal duplicates and overlap so the later scan can reason about disjoint spans. For the two current intervals, their possible shared span starts at the larger start and ends at the smaller end. It is emitted only when the start is strictly smaller than the end. A shared boundary therefore produces no empty interval.
After examining a pair, advance the interval that finishes earlier. It cannot intersect any later interval on the other side: those later intervals begin beyond the end of the other side’s current span, which has already reached at least as far. Keeping the shorter interval would only repeat a comparison that cannot produce new coverage. When both ends match, advancing both is safe.
The equal-end case deserves a named test because cursor code is easy to alter while simplifying branches. Advancing only one side on equality is also correct here, but can add a redundant comparison; an unconditional advance of both sides can skip valid intersections when one interval continues farther. The intended branch structure should be justified by the endpoint order rather than by whichever change makes an example terminate.
Because both inputs are normalized, the emitted intersections are already ordered and separated. They do not need a second normalization pass. There can be no adjacent output pieces arising from a hidden adjacency in one input, because that adjacency was merged before scanning. This reasoning depends on the normalization contract. If you remove that preparation for performance, you must require and validate a correspondingly stronger input contract.
Intersection represents common coverage, not matching records. If one collection describes a maintenance window and another describes unavailable positions, the result says where the two conditions coincide. It does not identify which maintenance task caused each result. Add provenance explicitly if a later step needs an explanation tied to source IDs.
Clip busy spans before finding gaps
A complement only makes sense relative to a universe. For this library, that universe is one nonempty horizon. Asking for all positions that are not busy without a horizon would have unbounded answers on both sides. The explicit parameter keeps the output finite and prevents a helper from guessing a working day, file size or measurement range.
The worked example uses horizon [0, 12) and busy intervals [-2, 3), [2, 5), [5, 7) and [9, 15). Normalizing the busy input produces [-2, 7) and [9, 15). Intersecting with the horizon clips those to [0, 7) and [9, 12). The only remaining free span is [7, 9).

The gap scan starts its cursor at the horizon’s start. Before each clipped busy interval, any distance from the cursor to that interval’s start is free. The cursor then moves to the busy interval’s end. After the scan, a final comparison captures any free tail before the horizon ends. Forgetting that final check is a common way to lose available space at the right edge.
Clipping first also makes outside data harmless to the calculation. An interval ending exactly where the horizon begins occupies none of the horizon. An interval starting exactly where the horizon ends also occupies none. A large interval covering the whole horizon leaves no gaps. With no busy input, the horizon itself is the only gap. Each case follows the same endpoint convention without separate calendar-specific rules.
Notice what the result does not promise. A free interval is a finding from the supplied snapshot. Another process may reserve it immediately afterward. If a service uses this result to accept a booking, it still needs a transactional conflict check or another concurrency design appropriate to its storage system. A correct pure function cannot make two independent read-then-write operations atomic.
from intervals import Interval, gaps, intersection, normalize, overlaps
busy = [Interval(-2, 3), Interval(2, 5), Interval(5, 7), Interval(9, 15)]
horizon = Interval(0, 12)
print("touching overlap:", overlaps(Interval(2, 5), Interval(5, 8)))
print("normalized:", normalize(busy))
print("inside horizon:", intersection(busy, [horizon]))
print("free:", gaps(horizon, busy))
Keep source records when identity or counts matter
Merging destroys information deliberately. The collections containing two identical intervals and containing one interval have the same normalized coverage. You cannot recover the original count from that result. If an application needs maximum simultaneous occupancy, billing per reservation or a list of affected customers, union coverage is insufficient. A sweep over start and end events or a richer segment structure would be a different project.
This loss matters when deleting records. Imagine bookings [0, 5) and [3, 8), whose union is [0, 8). Removing the first booking should leave [3, 8). Subtracting [0, 5) from the merged coverage instead would also remove positions 3 and 4 that remain occupied by the second booking. Recompute from retained records or maintain a representation that tracks contributions.
Separate resource identity as well. A reservation on machine A should not make the same coordinates busy on machine B unless the business rule explicitly couples them. Group by the relevant resource, unit and coordinate system before calling this library. A span carries no hidden context, so it cannot protect you from pooling unrelated data that happen to use the same numbers.
This separation is useful when working with an assistant. Ask it to list information preserved and discarded by each transformation. That question often surfaces a missing requirement earlier than asking whether an algorithm is efficient. For this lab, the answer should identify occupied positions as preserved and record multiplicity, ownership and history as discarded.
Test coverage with an independently built oracle
A test oracle should reach its answer by a route that is easy to trust and meaningfully different from the implementation. On a small integer domain, expand each interval into the unit positions it covers. Set union then gives expected normalized coverage; set intersection gives common coverage; subtracting occupied positions from the horizon gives free coverage. This deliberately inefficient representation is practical for small fixtures and avoids copying the two-cursor algorithm into the test.
For integer endpoints, each included integer position represents one elementary cell beginning there. An interval from 2 to 5 corresponds to the cells starting at 2, 3 and 4. Adjacent intervals meet cleanly at a cell boundary. The test can compare cell sets directly and independently check the structural form of the returned intervals. Large real-world coordinate ranges must never be expanded this way in production.
Coverage equality alone does not establish canonical form. Returning two touching intervals instead of one merged interval covers the same cells. Therefore tests also require strictly separated output spans, the correct tuple container and valid interval values. This catches representation bugs that a set comparison would conceal. The test suite checks both semantic coverage and the promised shape of the result.
Small exhaustive enumeration and larger seeded examples complement each other. Enumeration can explore every member of a bounded corpus, including awkward combinations that someone writing five examples might miss. Seeded generation reaches more varied shapes while remaining reproducible. Neither provides a proof over all possible integers, all iterable behavior or every future change. State the bounds and keep the seed with the test.
The downloadable lab includes the authored suite and a separate independent review suite. The author tests include all 24 permutations of the four-span worked input and 1,200 seeded pairs of collections. Validation tests cover empty and reversed intervals, rejected endpoint types, generator failures, input preservation and outside-horizon data. The exact independent corpus, interpreter versions and executed results are recorded with the download rather than inferred from a successful-looking code block.
Executed result: all 49 unittest methods passed under CPython 3.12.14 and 3.13.5, normally and with -O. The independent bit-mask oracle exercised 25,666 bounded exhaustive cases per configuration. Nine deliberately faulty variants were detected in every configuration. These are finite test results, not a correctness proof or performance benchmark.
Use properties that describe the contract
Useful properties express behavior across many inputs. Normalization should preserve coverage and be idempotent. Reordering the input or adding an exact duplicate should not change the normalized result. Intersection should be commutative in value, and its coverage should be a subset of each input’s coverage. These properties are connected to the function’s purpose, so a failure points toward a meaningful contract violation.
For gaps, combine the occupied coverage clipped to the horizon with the reported free coverage. Their union should equal the horizon, and their intersection should be empty. Every reported gap must lie entirely inside the horizon. Checking those relationships is stronger than merely asserting that gaps are sorted. A function that always returns an empty tuple is sorted, yet fails whenever any space is actually free.
Translation is another useful relationship. Adding the same integer offset to every endpoint and to the horizon should shift the output by that offset. This helps expose accidental assumptions that coordinates begin at zero or cannot be negative. Large offsets also exercise integer handling without requiring a test to materialize an enormous number of cells. Use algebraic comparisons for those cases.
Properties still need concrete examples. A failing generated case is much easier to understand after it is reduced to a pair such as [2, 5) and [5, 8). Keep that minimal counterexample as a named regression test. The property-based testing guide linked above discusses expanding this approach with a dedicated generator framework; the present lab remains standard-library-only.
Ask DeepSeek for counterexamples with explicit limits
A useful review request supplies the contract before the implementation. Without it, an assistant may reasonably assume closed intervals, preserve adjacency or accept empty ranges. Those choices can be coherent in another system while disagreeing with yours. Ask it to separate a defect under the stated contract from a suggestion that would change the contract.
The following prompt is designed for review after you have read the implementation. It asks for small executable findings and explicitly withholds any claim of test execution. Replace the final placeholder with code you are allowed to share. Avoid including private booking data, customer identifiers or production records; the small synthetic coordinates in this article are sufficient to investigate endpoint behavior.
Review this Python interval library against this exact contract.
Endpoints are exact built-in ints; start must be less than end.
Intervals are half-open: start included, end excluded.
normalize merges overlap and adjacency into a canonical tuple.
overlaps requires positive-length intersection.
intersection returns common coverage; gaps is bounded by its horizon.
Inputs are finite; results discard record identity and multiplicity.
For each suspected defect, provide:
1. The violated rule
2. The smallest concrete input you can find
3. Expected and actual output derived from the code
4. A runnable unittest regression test
5. Whether this is a code defect or a proposed contract change
Check nested intervals, equal endpoints, negative and huge coordinates,
empty collections, input validation and exceptions during iteration.
Do not claim you ran tests unless you actually executed them.
If you find no defect, describe the checked cases and remaining limits.
Implementation:
[paste intervals.py here]
Follow with a separate test-review question: ask which plausible wrong implementations would still pass the current suite. This can reveal missing assertions about canonical shape, outside-horizon clipping or the last gap. Request one faulty change and one test that detects it. Keep those experiments isolated from the implementation you intend to publish, and run the tests yourself before treating the result as evidence.
For a confusing finding, ask for a line-by-line trace of the two cursor positions and the current output. A trace that cannot reproduce the alleged result is a reason to examine the finding carefully. The workflow in evidence-based code review is a useful companion: retain actionable findings with reproducible inputs, and discard unsupported claims without assuming the entire review was useless.
Do not ask the model to certify universal correctness from a finite suite. A better final request is to summarize what was exercised, identify assumptions outside that evidence and suggest the next highest-value test. That keeps the review tied to an observable engineering decision. The primary DeepSeek API reference in the final sources describes a request interface, not a validation result for these particular prompts.
Recognize common wrong fixes
The first wrong fix changes every strict comparison to a non-strict comparison. That can merge adjacency correctly while incorrectly declaring touching intervals to overlap or trying to construct an empty intersection. Use separate expected results for each operation. Shared vocabulary should not hide the fact that the merge policy and overlap predicate have different boundaries.
The second wrong fix sorts only the output after processing unsorted input. The scan relies on sorted input to know that it has already seen the earliest relevant start. Sorting a broken result afterward cannot restore coverage that was incorrectly split, overwritten or skipped. Validate the invariant at the beginning of the scan, not merely the appearance of the final list.
The third wrong fix silently drops an interval with an end before its start. That may allow a report to finish, but it also hides invalid source data. This library rejects such values before aggregation. If an import pipeline needs quarantine instead, return an explicit rejected-record report at that boundary. Do not make “missing because malformed” indistinguishable from “absent because genuinely free.”
The fourth wrong fix expands every position to simplify production logic. That is acceptable for the bounded oracle, but a single interval may cover billions of positions. Endpoint-based algorithms scale with the number of intervals rather than the span length. Keeping the oracle and implementation different is an advantage only when each stays in the role for which it was designed.
Adapt units and calendars outside the core
Integer endpoints can model many domains, but conversion deserves as much attention as merging. For file positions, first establish that offsets use bytes rather than decoded characters. For video, decide whether values are frame indices or elapsed-time ticks. For a slot scheduler, define the slot duration and alignment. An apparently tiny unit mismatch can alter every resulting boundary.
For calendar use, convert validated instants into an agreed coordinate system before invoking interval operations, and format them afterward. A local wall-clock value can be ambiguous or nonexistent around a time-zone transition. The separate guide to date, time and daylight-saving logic addresses those inputs. This article does not demonstrate that adding a fixed number of ticks always means the same local calendar period.
Rounding introduces policy too. If source measurements have finer precision than your chosen integer unit, rounding each boundary can shrink coverage, expand it or collapse a short interval. Decide which consequences the application permits. Preserve the original value when auditability matters, and test conversion separately from union and intersection. Passing the interval suite does not validate an upstream rounding decision.
Resource identifiers, permissions and accepted booking state likewise belong outside this pure coverage layer. A reporting function can calculate an answer from an authorized snapshot. A write workflow must decide whether that snapshot is current enough, enforce its own access rules and commit changes safely. Keeping those responsibilities separate makes it easier to state exactly what a successful interval test does establish.
Understand the cost before optimizing
For a finite collection of n intervals, normalization sorts the input and performs one linear scan. In the usual comparison-count model, the sorting stage is O(n log n), with O(n) auxiliary storage for the copied input and output. Intersection normalizes both sides and then scans them with two cursors. Gaps adds a scan over the clipped busy spans. These are algorithmic descriptions, not measured throughput claims.
Python integers can have very large magnitudes, so treating every endpoint comparison as a constant-cost operation is a simplifying model. Input copying also means memory use depends on the number of intervals. The implementation has no configured record-count limit and cannot finish consuming an infinite iterable. Put workload limits at the application boundary when inputs come from files or requests of uncertain size.
If profiling later shows repeated normalization to be expensive, consider an explicit normalized-value type whose constructor validates its invariant. That would support a separate fast path without letting arbitrary callers pretend that unsorted input is safe. Do not add that abstraction merely to shorten a tiny example; it introduces an additional contract, and its construction and reuse need tests of their own.
Run the lab and review the evidence
Save the implementation as intervals.py or download the complete lab below. The archive includes the demonstration, authored tests, independent tests and a verification record. It needs no external Python packages, credentials, network calls or model access. Open a terminal in the extracted lab folder, alongside intervals.py. Run the demonstration first so you can compare its concrete outputs with the worked diagram, then execute the full test suite.
python3 demo.py
python3 -m unittest discover -v
python3 -O -m unittest discover -v
Download the original Python interval logic lab, including the implementation, demonstration, authored and independent tests, and full reader instructions.
The optimized run is intentional. Python can remove ordinary assert statements under optimization, so input validation should use explicit checks and exceptions. The lab’s unittest assertions remain test-method calls. Running both modes helps detect accidental reliance on an assertion for required behavior, although it does not substitute for inspecting the implementation or understanding what each test checks.
Before adopting a change, rerun the suite against the actual file you plan to ship. If code is copied into an article, documentation page or internal runbook, extract and test that copy too. Formatting changes can alter indentation or comparisons even when the source file was correct. Keep the demonstrated output, source version and test result together so future readers can reproduce the same claim.
Practical questions about interval behavior
Why reject empty intervals?
An empty interval contributes no coverage, but it can also signal a conversion mistake or an event that needs another representation. This lab chooses a strict constructor so those cases receive attention. A different library could accept empty intervals and remove them during normalization, provided its membership, length, equality and output rules are documented and tested consistently.
Can I keep touching spans separate?
Yes, with a different normalization contract. Preserving adjacency is useful when the boundary carries business meaning. However, coverage equality alone would then permit several representations of the same union. Decide whether boundaries are data or merely an incidental result of input order, and update the invariants, diagrams, tests and any downstream assumptions together.
Does a free gap guarantee a booking will succeed?
No. It describes free coverage in the input snapshot and within the given horizon. A booking service must still check resource identity, current availability, permissions and concurrent writes. The pure functions are useful building blocks for explaining that calculation, but they do not communicate with a storage system or reserve anything.
What should I ask an AI reviewer to deliver?
Ask for the smallest counterexample, the rule it violates, a runnable regression test and a clear statement of whether the reviewer actually executed it. Keep accepted findings alongside the tests they introduced. That turns an open-ended conversation about “correct code” into a reviewable chain from contract to example to evidence.
Sources & References
The primary documentation below was checked on October 7, 2026. It supports Python library behavior and the DeepSeek request interface. The interval contract, algorithms, examples, illustrations and tests are original work for this guide; the documentation does not certify their correctness. Versioned Python documentation may display a newer patch release than the exact interpreters used in the verification record.
- Python dataclasses documentation: generated methods, post-initialization checks and frozen-instance behavior
- Python Sorting HOWTO: explicit keys, sorted copies and in-place sorting
- Python built-in types and ranges: integer behavior and stop-exclusive ranges
- Python unittest documentation: test discovery and exception assertions
- Python command-line optimization options: the effect of optimized execution on assert statements
- DeepSeek chat completion API reference: request interface reference for an optional review integration

[…] whether one duration contains another. Those problems require a different data model, explored in Python interval logic. Reusing half-open notation is helpful, but it does not make a single-key index an interval index. […]