QUICK REFERENCE
Conversion checklist
Use this sequence to turn supported Python functions into C that you can build and test confidently.
Prepare the Python
- Start with a small function whose expected results you know.
- Annotate each parameter and return value with a supported type.
- Assign every local before reading it, including after branches and loops.
- Keep each variable's type consistent. Use
1.0 when you mean a float.
- Keep module values constant during function calls. Pass changing values as parameters.
- Check string operations against the supported string table.
Convert and correct errors
- Add all files needed by function imports. Remove unintended empty modules.
- Choose Transpile Source Bundle, or run
pycforge convert input.py --output output.c.
- If conversion is rejected, open the first diagnostic and fix the indicated source. An annotation does not make an unsupported expression convertible.
- Convert again after each correction. Save C only when the result is current and successful.
Build with your C toolchain
PyCForge produces C source. It does not compile or run it. A converted function is not automatically a standalone program with main. Compile the output as part of your C application, or use a small C test program that calls the generated function.
For example, use an installed GCC compiler to check and compile the output to an object file.
gcc -std=c11 -Wall -Wextra -c output.c -o output.o
Review compiler messages and the generated function declarations. String arguments need valid UTF-8 storage; file functions add an error-status argument and may return memory you must release. See passing strings from C and checking file errors.
Compare results with Python
- Check ordinary inputs and boundary cases, including zero, negative numbers, and values near your application's limits.
- Exercise both sides of branches, empty loops, and loops that stop with
break.
- For strings, include empty text, non-ASCII characters, a missing match, and a match at each end.
- For file functions, test missing paths, invalid text, and files larger than the configured read limit.
- Keep integer arithmetic within the signed 64-bit range. Do not assume Python's arbitrary-size integers carry over to C.
Keep a reproducible example
Save the Python inputs, the PyCForge version, the generated C, and your test inputs and expected results. When reporting a problem, reduce it to the smallest example that still shows the issue, and include the exact diagnostic or compiler message.