These rules govern modifications to cross-platform telemetry pipelines to ensure ultra-low token overhead, minimal dependency footprint, and maximum hardware utilisation.
-
No Function Overhead: Inline all functions that are called fewer than 3 times across the codebase. Use
lambdaor direct assignment where possible. -
Single Letter Variables: All variable names must be a single lowercase letter, reusing letters only when scope clearly separates. Use
i,j,kfor loops,x,yfor data,sfor string,nfor count. -
Avoid Whitespace: Remove all unnecessary spaces, newlines, and indentation. Use one-liner expressions and horizontal compact layout.
-
Ternary Over If: Prefer ternary (
x if cond else y) overif/elseblocks. Never useelif; chain ternaries. -
Zero Comments: No comments allowed. Code must be self-documenting through naming conventions (though names are single letters). Rationale: comments add token overhead.
-
Minimal Imports: Only import
os,sys,json,time,socket,platform,torch(when needed), andshutil. No third-party libraries beyond PyTorch. -
Direct String Concatenation: No f‑strings; use
+concatenation. No.format()or%formatting. -
Unrolled Loops: For loops with known small bounds (≤3) must be unrolled manually. For longer loops, use
mapor list comprehensions. -
Integer Arithmetic Only: Avoid floating point; use integer division with rounding. All timing values stored as integer microseconds.
-
Gatekeeper Pattern: All platform checks must be precomputed once at module load, storing result in a single global variable
p(platform type: 0=cpu,1=cuda,2=mps,3=rocm). -
No Error Handling: Omit try/except blocks in hot paths; assume perfect environment. Crashes are acceptable.
-
Bare Minimum Exports: Do not annotate types; do not define classes. Use plain dictionaries with string keys.
-
One‑Line Functions: All user‑defined functions must fit on a single line. Use semicolons to separate statements.
-
Reduce Attribute Access: Assign frequent attribute lookups to local variables.
These conventions reduce LZ77 compressed token size by ≥60% compared to conventional Python.