ordering

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Benchmark 6: version ordering against registry order

Phase 0 benchmark 6 (architecture.md §6, story angelia-dev/angelia#55): our version schemes (ADR 0007) must order real version lists exactly as each registry's own tooling does.

make bench-ordering            # = go run ./bench/ordering; offline, reads testdata/ only
make bench-ordering-snapshot   # rebuild the snapshots from the live registries

CI runs make bench-ordering in the bench-ordering job, which is part of CI OK. go test ./bench/... runs the same comparison too (skipped with -short).

A hollow snapshot does not pass: the run fails when a snapshot has fewer than -min-packages (default 100) packages or -min-versions (default 10,000) versions, when its meta.versions does not match the versions in the file, or when meta.missing names packages of the list that the registry did not return.

What is compared

Registry Versions Reference order ("oracle") Our scheme
PyPI every version of the project, from the Simple API (PEP 691 JSON, PEP 700 versions) packaging.version.Version (what pip and pypi.org use) schemes.Select("pypi"): PEP 440 with lexical fallback
npm the version keys of the abbreviated packument node-semver semver.compare, strict (npm picks versions with semver.rcompare) schemes.Select("npm"): strict SemVer with lexical fallback

The snapshot scripts compute the oracle order when they fetch, and store it. Versions of equal precedence form one group: 1.0 and 1.0.0 in PEP 440, 1.0.0+a and 1.0.0+b in SemVer (build metadata never counts for precedence, as in npm).

For each package the tool reports three kinds of mismatch:

  • rejected: the oracle accepts a version, our scheme does not (it would fall back to lexical and rank below every valid version);
  • accepted: the oracle rejects a version, our scheme parses it;
  • order: two versions that are adjacent in the oracle's order compare differently with our scheme (< expected, got = or >; or = expected inside a group). The versions are then shuffled deterministically and sorted with our Compare; when the result differs from the oracle's order, the report prints both orders around the first difference (-json writes them in full).

Versions the oracle rejects are not ordered: PyPI has 103 of them in this snapshot (legacy strings such as 0.1-bulbasaur or 1.0beta5prerelease, which pip ≥ 24.1 ignores); our scheme must reject them too (accepted otherwise), and our fallback ranks them below every valid version.

Result (snapshot of 2026-11-01)

Registry Packages Versions Mismatches
PyPI (packaging 26.3) 508 59,877 0
npm (node-semver 7.7.4) 421 148,745 0

Package set

The issue asks for the top 1,000 packages of each registry. Neither download ranking was reachable when the snapshot was built: the agent sandbox could reach only pypi.org and registry.npmjs.org, not api.npmjs.org (npm download counts) nor the public "top PyPI packages" dataset or BigQuery. So the lists in packages/ are curated, not a ranking:

  • the most-downloaded packages of each registry as commonly listed (for example boto3, urllib3, requests, numpy; lodash, react, chalk, @types/node), and the dependencies they pull in;
  • packages with unusual version histories on purpose: on PyPI legacy and calendar versions (setuptools, pytz, certifi, pywin32, paramiko, boto), pre-, post- and dev-releases (django, numpy, hypothesis, pillow, traitlets, kubernetes); on npm long pre-release trains and nightly or canary builds (typescript, next, react, prisma, @prisma/client, playwright, electron, vue, webpack, @angular/core).

Every listed package existed when the snapshot was built (meta.missing is empty). To run the benchmark on a true top-1,000 set, replace the lists (one name per line) and rebuild the snapshot where the registries are reachable; nothing else changes. Both snapshots together stay well under 1 MB compressed (about 630 KB).

Snapshot format and reproducibility

testdata/<registry>.jsonl.gz is gzip'd JSON lines. Line 1 is {"meta": {"registry", "source", "oracle", "generated", "packages", "versions", "missing"}}; each further line is {"name", "order": [[version, ...], ...], "invalid": [...]}, sorted by name. The gzip header has no timestamp, so rebuilding on the same day from unchanged registry data gives identical bytes (checked when this snapshot was made). Registries only add versions, so a later rebuild may add versions and packages but should not change the order of existing ones.

Rebuilding needs Python 3 with packaging (pip install packaging==26.3) and Node.js with npm (node-semver is taken from SEMVER_PATH, or else from the global npm's bundled copy, with a warning naming its version). The scripts use only those and their standard libraries, and contact only pypi.org and registry.npmjs.org.

Known mismatches

known-mismatches.json lists mismatches the maintainer has accepted, each with an explanation and an issue reference. A listed mismatch does not fail the run; an unlisted one does, and so does an entry that no longer matches anything (remove it). The list is empty: the comparators match both registries on this snapshot.

Do not add an entry, or change a comparator to follow a registry quirk, without the maintainer's decision (issue #55, "Human needed?").

Documentation

Overview

Command ordering is Phase 0 benchmark 6: it checks that our version schemes order real PyPI and npm version lists exactly as the registries' own tooling does (packaging for PyPI, node-semver for npm).

It reads committed snapshots (see snapshot/ and README.md), never the network, so CI can run it offline:

go run ./bench/ordering

A snapshot below -min-packages or -min-versions, or with packages the registry did not return, is an error: a hollow snapshot must not pass.

Exit status: 0 when every mismatch is listed in the known-mismatch file (and no entry there is stale), 1 otherwise, 2 on usage or I/O errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL