Files
typthon/RENAMING_GUIDE.md
2025-12-29 22:19:03 +00:00

4.7 KiB

Typthon Renaming Guide

This document tracks the ongoing effort to rename Python/Py* prefixes to Typthon/Ty* throughout the codebase.

Overview

Typthon is a fork of Python that aims to become a strictly typed language. As part of this transformation, we're systematically renaming all Python-related prefixes to Typthon equivalents.

Completed Renamings

Phase 1: Core API Functions (Completed in PR #21)

  • Basic Py* → Ty* renames for most of the codebase
  • Core Python API functions
  • Type system functions
  • Object management functions

Phase 2: Build System Fixes (This PR) COMPLETE

Python/crossinterp.c

  • PyMem_RawCallocTyMem_RawCalloc (7 occurrences)
  • PyMem_RawMallocTyMem_RawMalloc (2 occurrences)
  • PyThreadState_GetTyThreadState_Get (5 occurrences)
  • PyThreadState_SwapTyThreadState_Swap (8 occurrences)
  • PyThreadState_ClearTyThreadState_Clear (2 occurrences)
  • PyThreadState_DeleteTyThreadState_Delete (2 occurrences)
  • PyThreadState_GETTyThreadState_GET (1 occurrence)
  • PyThreadState_GetInterpreterTyThreadState_GetInterpreter (4 occurrences)
  • PyInterpreterState_GetTyInterpreterState_Get (5 occurrences)
  • PyInterpreterState_GetIDTyInterpreterState_GetID (3 occurrences)
  • PyInterpreterState_GetDictTyInterpreterState_GetDict (1 occurrence)
  • PyInterpreterState_DeleteTyInterpreterState_Delete (1 occurrence)
  • PyMarshal_ReadObjectFromStringTyMarshal_ReadObjectFromString (1 occurrence)
  • PyMarshal_WriteObjectToStringTyMarshal_WriteObjectToString (1 occurrence)

Python/specialize.c

  • _Py_OPCODE_Ty_OPCODE (2 occurrences)
  • _Py_Specialize_*_Ty_Specialize_* (14 function definitions):
    • _Ty_Specialize_LoadSuperAttr
    • _Ty_Specialize_LoadAttr
    • _Ty_Specialize_StoreAttr
    • _Ty_Specialize_LoadGlobal
    • _Ty_Specialize_StoreSubscr
    • _Ty_Specialize_Call
    • _Ty_Specialize_CallKw
    • _Ty_Specialize_BinaryOp
    • _Ty_Specialize_CompareOp
    • _Ty_Specialize_UnpackSequence
    • _Ty_Specialize_ForIter
    • _Ty_Specialize_Send
    • _Ty_Specialize_ToBool
    • _Ty_Specialize_ContainsOp
  • _Py_InitCleanup_Ty_InitCleanup (1 occurrence)

Modules/atexitmodule.c

  • Py_BEGIN_CRITICAL_SECTIONTy_BEGIN_CRITICAL_SECTION (1 occurrence)
  • Py_END_CRITICAL_SECTIONTy_END_CRITICAL_SECTION (1 occurrence)

Include/internal/pycore_bitutils.h

  • _Py_bswap32_Ty_bswap32 (1 function definition)

Modules/posixmodule.c

  • Py_off_t_converterTy_off_t_converter (function definition and all references)
  • Updated clinic converter class name

Build Status

BUILD SUCCESSFUL!

The Typthon interpreter now builds without errors:

  • All Py→Ty prefix issues resolved
  • Linker successfully resolves all symbols
  • Executable runs and shows version information
  • Help system works correctly

Test Results

$ ./typthon --version
Typthon 3.14.0b4+

$ ./typthon --help
usage: ./typthon [option] ... [-c cmd | -m mod | file | -] [arg] ...
[... help output ...]

Remaining Work

Directory Structure Rename (Future PR)

  • Rename Python/ directory to Typthon/
  • Update all references in CMakeLists.txt
  • Update all #include paths
  • Update documentation

Strict Typing Implementation (Future PRs)

  • Document strict typing architecture
  • Design type system modifications
  • Implement compile-time type checking
  • Add type annotations enforcement
  • Create type inference engine

Impact on Strict Typing Goals

The renaming work is a prerequisite for implementing strict typing in Typthon because:

  1. Clear Identity: Establishes Typthon as distinct from Python
  2. Clean Foundation: Ensures all APIs use consistent naming
  3. Future Extensibility: Makes it easier to add new typed features without confusion
  4. Documentation: Makes it clear what belongs to Typthon vs. Python compatibility layers

Testing

Build verification completed:

  • Code compiles without syntax errors
  • Linker resolves all symbols successfully
  • Executable builds successfully
  • Version output works: typthon --version
  • Help works: typthon --help
  • Full test suite (pending)

Notes

  • Some references to "Py" in comments are intentionally left unchanged when they refer to the Python compatibility or origin
  • Build is now fully functional with all Py→Ty renames complete in core runtime files
  • The Python/ directory name itself is left as-is for now to minimize disruption; will be renamed in a future PR
  • All functional code now consistently uses Ty* prefixes