QUICK REFERENCE
Use this sequence to prepare Python, convert it, and verify the generated C in your own build environment.
Use the dedicated PCFC11 Compile dialog, or Transpile → Other C Compilers… for GCC/MinGW-w64, Clang, MSVC or Clang-cl. The commands below show the equivalent external GCC workflow.
PyCForge emits source. Use a C application or test harness to call the generated functions. To compile a typed output to an object file with GCC:
gcc -std=c11 -Wall -Wextra -c output.c -o output.o
For runtime output with a Python main() callable without arguments, enable its optional entry wrapper:
gcc -std=c11 -DPYCF_RUNTIME_MAIN output.c -o program -lm
Follow typed string ownership and file status handling for typed output, or context lifetime and runtime errors for runtime output. Review compiler messages before running the program.
Convert the add example to example.c. Save the following as caller.c in the same directory. Including the generated C makes its exact declarations available to this small standalone caller.
#include <inttypes.h>
#include <stdio.h>
#include "example.c"
int main(void)
{
printf("%" PRId64 "\n", add(2, 3));
return 0;
}
With a compatible GCC toolchain, build only the caller; do not also pass example.c, because it is already included:
gcc -std=c11 -Wall -Wextra caller.c -o caller
Run ./caller on Linux/macOS, or .\caller.exe in Windows PowerShell. It prints 5. For a larger C project, use matching declarations in a header and compile generated C as a separate translation unit.
break.The SDK's Dictionary records and dialects starter provides these same public kernels under the independent recordio namespace. Change package, namespace and export names through the authoring workflow.
Declare *import csv in Runtime mode. CSV 0.2 supplies lazy sequence and dictionary readers, text-file writers, six quoting modes, escaping, immutable dialect snapshots and a context-local dialect registry. This is a bounded interface, not full Python csv compatibility.
| Interface | Supported behavior |
|---|---|
reader(iterable, /, dialect=None, **fmtparams) | Fresh lists; physical Unicode input lines, including quoted embedded newlines. Read-only line_num counts string input items. A non-string item raises csv.Error without incrementing it. |
DictReader(f, fieldnames=None, restkey=None, restval=None, dialect='excel', **fmtparams) | The first record becomes headers when omitted; supplied list/tuple headers retain identity, and other admitted iterables are materialized. Results are ordered dictionaries; duplicate headers keep the last value. Blank data records are skipped. Extra columns become a list under restkey; missing columns use the retained restval. Reading fieldnames loads missing headers lazily. |
writer(file, /, dialect=None, **fmtparams) | writerow(row, /) returns Unicode characters written; writerows(rows, /) returns None. Fields admit str, int64, finite float64, bool and None. |
DictWriter(f, fieldnames, restval='', extrasaction='raise', dialect='excel', **fmtparams) | Runtime dictionary rows, explicit column order and missing-value fallback. extrasaction is case-insensitive raise or ignore; extra keys raise ValueError in raise mode. writeheader() writes headers and returns the character count. Single-row and multiple-row methods use the same rules; writerow(rowdict=...) and writerows(rowdicts=...) are accepted. |
Here **fmtparams describes the fixed named settings below. Source-level *args/**kwargs expansion is unsupported. Names before the slash are positional-only. The dictionary constructors also accept their leading arguments by name.
*import csv
def main():
rows = csv.DictReader(['name,value\n', '"north,west",12\n', 'south\n'], restval="0")
print(rows.fieldnames)
with open("records.csv", "w", encoding="utf-8", newline="") as output:
writer = csv.DictWriter(output, ["value", "name"], lineterminator="\n")
writer.writeheader()
writer.writerows(rows)
print(rows.line_num)
return 0
The example prints the headers and line count, and writes value before name. Use UTF-8 text files with newline="". Reader and writer aliases share state and retain their source/file; neither closes the caller's file. Keep use inside its with block.
Settings are delimiter, quotechar, escapechar, doublequote, skipinitialspace, lineterminator, quoting and strict. Individual settings override the selected dialect. Character options accept one Unicode scalar; quotechar/escapechar can be None. They must differ and cannot be CR/LF; quote/escape cannot be a space with skipinitialspace=True, following Python 3.13 validation. Empty character strings raise TypeError. quotechar=None implies QUOTE_NONE when quoting is omitted. The reader recognizes CR/LF independently of lineterminator.
| Constant | Writer and reader behavior |
|---|---|
| QUOTE_MINIMAL (0) | Quote fields containing separators, newlines, quote characters or terminator characters; reader returns strings. |
| QUOTE_ALL (1) | Quote every field; reader returns strings. |
| QUOTE_NONNUMERIC (2) | Quote nonnumeric fields; convert nonempty unquoted fields to float64. |
| QUOTE_NONE (3) | Never quote; escape special characters with escapechar or raise csv.Error. Reader treats quote characters as ordinary text. |
| QUOTE_STRINGS (4) | Quote strings; write None as an empty unquoted field. Reader converts nonempty unquoted fields to float64 and empty unquoted fields to None. |
| QUOTE_NOTNULL (5) | Quote values except None; reader returns None for empty unquoted fields and strings otherwise. |
The last two modes were introduced in Python 3.12; this profile uses corrected Python 3.13+ reader semantics, not the Python 3.12 reader bug. A sole None field raises csv.Error in these modes, matching Python 3.13.5: an entirely blank record cannot distinguish it from no fields. A sole empty field also raises csv.Error under QUOTE_NONE. doublequote=True doubles embedded quote characters; False requires escapechar when a quote needs escaping. escapechar itself is escaped. Numeric parsing retains the Runtime finite-float boundary: invalid/nonfinite text raises ValueError; overflowing finite text raises OverflowError.
excel, excel-tab and unix are initially registered. Use register_dialect(name, /, dialect=None, **fmtparams), get_dialect(name, /), unregister_dialect(name, /) and list_dialects(). Registration and constructors accept a registered name or immutable get_dialect snapshot. An omitted or None dialect selects fixed Excel defaults; DictReader/DictWriter default to the named excel registration. Replacing or removing a name does not change previously constructed readers/writers.
The registry is shared by profile-0.2 namespaces and supplied modules within one generated Runtime context. It is neither process-global nor persistent; separate C contexts are independent. At most 128 names are registered, and names/terminators have a 1024-byte UTF-8 limit. Dialect subclasses, arbitrary format objects, csv.excel/unix class constructors and custom write callbacks are unsupported. Snapshot properties are immutable. Reader/writer attributes are read-only, though retained fieldname lists can be edited; dictionary wrapper .reader/.writer attributes are not exposed. DictReader.dialect reports its immutable snapshot rather than the original name argument.
Catch malformed CSV, unknown dialects, non-string input items, impossible escaping and field/record format limits with except csv.Error:, including import aliases or tuples of exception types. It is separate from ValueError. Invalid arguments use TypeError or ValueError; extra dictionary keys and invalid numeric text use ValueError. File operations retain OSError and closed-file ValueError. Allocation, work and depth exhaustion remain fatal resource failures and cannot be caught as csv.Error or Exception. Qualified literal raise csv.Error("message") is supported; exception objects, as e, first-class Error aliases and bare re-raise remain unsupported.
A field is limited to 131072 Unicode scalars, a row to 16384 fields and input/output record text to 1 MiB of UTF-8; Runtime budgets can be exhausted first. Malformed partial rows are discarded without rewinding input. Each output row is fully formatted before writing; earlier writerows output and partial device writes are not rolled back. Headers, rest values, dialects and bound methods are traced during garbage collection; collection is deferred while files are open.
Sniffer, field_size_limit, bytes, arbitrary scalar/object stringification and general Python csv compatibility remain outside this interface. The independent dictionary-records starter exposes these same reusable contracts. Legacy delimited-records/0.1 packages keep their original two-operation format and ValueError behavior.
The SDK's Lazy record pipelines starter exposes reusable chain, islice and pairwise operations under an independent namespace. The bundled itertools package uses these same contracts. Iterators retain their inputs and share their position through aliases. Exhaustion releases retained references; caller-owned files remain open until their own close or with-block exit.
*import itertools as it
def main():
readings = it.chain([10, 12], [15, 21])
for before, after in it.pairwise(it.islice(readings, 1, None)):
print(after - before)
return 0
This prints 3 and 6 on separate lines. chain accepts zero to eight positional inputs; islice accepts its two-, three- or four-argument form; pairwise accepts one input. Keywords, argument expansion, custom iteration hooks, generators and other itertools members are unsupported. Consult Import Help for input types, error recovery and work limits. Keep file-backed pipelines inside the file's with block.
The SDK's Author-defined measurement formulas starter supports new scalar logic through expression and ordered binding fields. Registered formulas can be called with their advertised positional/named/default arguments in Runtime programs and supplied modules. The initial profile accepts finite numbers and returns float64 or bool; it does not define new objects, iterators or binary buffers.
Each formula declares a bounded expression using arithmetic, comparisons, Boolean conditions and abs/sqrt/min/max primitives. An intermediate such as corrected = value - offset can be used in corrected * gain. Conditional expressions evaluate only their selected branch. Consult the package's Import Help for its exact formula and the engine-owned numerical, error and work limits.
SDK conversion verification does not run C or establish expected output. Compile and exercise the complete application in PyCForge, including errors and boundary values. A changed formula requires fresh conversion evidence and native qualification for its claimed behavior.
Keep the Python source, selected mode, settings, package version, generated C, test inputs, and expected results together. For a problem report, reduce the source to the smallest example that reproduces it and include the exact diagnostic or compiler message.