Python-to-Objective-C bridge providing seamless interoperability between Python and Objective-C programming languages on macOS systems.
—
Essential bridge components that provide the foundation for Python-Objective-C interoperability, including constants, context management, and fundamental runtime integration features.
Standard Objective-C constants mapped to Python equivalents for seamless code compatibility.
nil = None
"""Objective-C nil constant, equivalent to Python None."""
YES = True
"""Objective-C YES constant, equivalent to Python True."""
NO = False
"""Objective-C NO constant, equivalent to Python False."""Context manager for managing NSAutoreleasePool instances, essential for memory management when working with Objective-C objects.
class autorelease_pool:
"""
Context manager that runs the body of the block with a fresh autorelease pool.
The actual release pool is not accessible.
"""
def __init__(self): ...
def __enter__(self): ...
def __exit__(self, exc_type, value, tp): ...Usage Example:
import objc
# Use autorelease pool for memory management
with objc.autorelease_pool():
# Work with Objective-C objects here
# Pool will be automatically drained when exiting the context
passUtility functions for name resolution and runtime introspection.
def _resolve_name(name):
"""
Resolve a dotted name to a Python object.
Args:
name (str): Dotted name like "module.submodule.function"
Returns:
object: The resolved Python object
Raises:
ValueError: If name doesn't contain dots
"""The core bridge functionality is provided through the objc._objc C extension module, which includes:
This C extension is automatically imported and its namespace is merged into the main objc module, providing seamless access to all bridge functionality.
Install with Tessl CLI
npx tessl i tessl/pypi-pyobjc-core