The CCL Python interface is a two-layer system built using SWIG.
- SWIG Layer (
pyccl.ccllib): This is the autogenerated interface that scans CCL C headers and maps them to Python. It handles the conversion of C array arguments to numpy arrays and manages function name mapping (e.g., removing the ccl_ prefix). - Python Wrapper Layer: This is the user-facing API. It provides a more friendly interface and handles high-level logic. Most modern calculations are implemented directly in Python; C is reserved for performance-critical calculations.
Important Note on Global State: All global state in the C library (such as power spectra spline initialization) is managed by the Python layer. Before calling C-level functions, ensure internal C data is initialized. You can use methods on the pyccl.Cosmology object, such as compute_distances(), to ensure the necessary state is prepared.