Skip to content

Centralize Public API into dedicated API module #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 20, 2025
Merged

Centralize Public API into dedicated API module #648

merged 22 commits into from
Jul 20, 2025

Conversation

cjdoris
Copy link
Collaborator

@cjdoris cjdoris commented Jul 20, 2025

This PR implements a comprehensive refactoring to centralize PythonCall.jl's public API into a dedicated module structure.

Key Changes

New Centralized API Module

  • Created src/API/ directory with organized API components:
    • types.jl - All public type definitions
    • functions.jl - Public function declarations
    • macros.jl - Public macro declarations
    • exports.jl - Centralized export statements
    • publics.jl - Public API declarations using modern Meta.parse() pattern

Type System Reorganization

All major types moved to centralized API:

  • Core types: Py, PyException, pybuiltins
  • Wrapper types: PyArray, PyDict, PyIO, PyIterable, PyList, PyPandasDataFrame, PySet, PyTable
  • JlWrap types: PyObjectArray, PyObjectVector, PyObjectMatrix (with updated Ptr{Cvoid} storage)
  • Convert types: Priority enums for conversion system

Function and Macro Centralization

  • JlWrap functions (pyfunc, pyclassmethod, pystaticmethod, pyproperty, etc.)
  • The pytable function from Compat
  • The @py macro from PyMacro
  • The @pyconst macro from Core
  • All Core builtin functions

Module Structure Updates

  • Individual modules now import from centralized API rather than defining their own types
  • Eliminated local exports in favor of single-source exports
  • Consistent import patterns across entire codebase

Technical Improvements

  • PyObjectArray uses Ptr{Cvoid} instead of C.PyPtr for improved type safety
  • Clean public API declarations using modern Julia patterns
  • Removed redundant exports and simplified module dependencies

Impact

This refactoring establishes a clear architectural boundary between PythonCall's public API and internal implementation. It reduces code duplication, improves maintainability, and provides users with a single, well-defined interface while preserving full backward compatibility.

The centralized approach makes the codebase more modular and easier to extend, setting up a foundation for future API evolution.

@cjdoris cjdoris merged commit c0a5634 into main Jul 20, 2025
14 checks passed
@cjdoris cjdoris deleted the api branch July 20, 2025 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant