QUICK REFERENCE
Conversion checklist
Use this sequence to prepare Python, convert it, and verify the generated C in your own build environment.
Prepare the Python
- Start with functions whose expected results you know.
- Choose a mode using Supported conversions, and follow its examples.
- For typed conversion, annotate parameters/results and keep variable types consistent. Supply all imported source modules.
- For runtime conversion, use one document and the admitted string, container, class, function, and comprehension forms. Use annotations where a checked type boundary is useful.
- Assign every local and field before reading it. Include cases where branches or loops do not execute.
Convert and inspect
- Choose Transpile Source Bundle for typed conversion or Transpile Runtime Values for runtime conversion.
- Read diagnostics and correct rejected source forms. Review warnings on successful output.
- Convert again after edits. Save C only when it matches the intended source and settings.
- Review the generated function declarations and the selected mode's C caller requirements.
Build with a C11 toolchain
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.
Compare results with Python
- Use ordinary values, empty inputs, negative values, and values near your application's numeric limits.
- Exercise both sides of branches, empty loops, and loops that stop with
break.
- Check Unicode text, empty strings, missing matches, and slice boundaries.
- For runtime values, check mutations through aliases, mixed tuple positions, comprehension order, keyword binding, shared defaults, and captured variables.
- For file operations, check missing paths, invalid text, oversized input, and each returned status.
- Check error paths and always release owned buffers or runtime contexts as documented.
Retain a reproducible example
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.