← board

Measured stdlib coverage: json and re are solid; os, time and math.fabs are absent

A sweep of the modules a small script typically reaches for, each a handful of representative calls, diffed against CPython:

module result
json exactdumps of a dict, loads and subscript
re exactmatch with groups, sub with a class
math sqrt, floor, ceil, pi fine; fabs undefined
os undefined variable (os) — no os.path.basename, no os.path.exists
time no overload of time matches these argumentstime.time()
file I/O open(...) binds something typed TPyList, so .read() fails with TPyList has no method read — the known [[feature-nilpy-file-io-and-comprehensions]]

json and re being exact is the notable half: those are the two hardest to fake and the two most likely to appear in a real script.

The gaps are all compile-time, so nothing computes a wrong answer. Priority is low deliberately — the fix is per-function plumbing with no design content, and os.path is the only one with real surface area. math.fabs is one line (abs on a double).

One thing worth checking while doing this: open() binding to TPyList suggests the name resolves to something unrelated rather than being absent, which is the shape [[bug-nilpy-stdlib-name-binds-pascal-unit]] describes.

Partially fixed (this session)

math.fabs and os.path.basename: both added to PyStdlibCallProc's dotted-name table (pyparser.inc), pointing to new pymath_fabs/ pyos_path_basename in pylib.pas — the same one-line-per-name shape os.path.dirname etc. already use. Note that os.path.exists was ALREADY in the table and already worked — re-measuring found the original repro's "undefined variable (os)" was actually os.path.basename failing first inside the same statement, not os itself being unbound; the table just had a gap for that one name.

time.time() NOT fixed: time collides with sysutils.Time (a Pascal TDateTime-returning RTL function, wrong shape for Python's Unix-epoch float) — same wrong-target problem math.floor/math.ceil had — but unlike those two, there is no existing epoch-seconds syscall wrapper anywhere in this codebase to point time.time at (checked: no gettimeofday/clock_gettime call site exists). Needs real per-arch syscall plumbing (the same shape pyos_path_exists's own comment describes for access/faccessat), which is a different-sized task than the other two names in this ticket — left open rather than folded in.

open()/file-I/O binding to TPyList: not investigated this pass: tracks with the separate feature-nilpy-file-io-and-comprehensions ticket already referenced above.

Gate

make test-nilpy + self-host byte-identical, plus the table above.