Python-to-Objective-C bridge providing seamless interoperability between Python and Objective-C programming languages on macOS systems.
—
Functions for registering Python types with the bridge system and comprehensive SIMD type support, enabling seamless integration between Python data types and Objective-C collections and high-performance operations.
Functions for registering Python types to work seamlessly with Objective-C collection classes.
def registerListType(type_object):
"""
Register a list-like type for NSMutableArray proxying.
Args:
type_object: Python type that behaves like a list
Enables automatic conversion between the Python type and NSMutableArray.
"""
def registerMappingType(type_object):
"""
Register a dict-like type for NSMutableDictionary proxying.
Args:
type_object: Python type that behaves like a dictionary
Enables automatic conversion between the Python type and NSMutableDictionary.
"""
def registerSetType(type_object):
"""
Register a set-like type for NSMutableSet proxying.
Args:
type_object: Python type that behaves like a set
Enables automatic conversion between the Python type and NSMutableSet.
"""Functions for registering specialized Python types with corresponding Objective-C classes.
def registerDateType(type_object):
"""
Register a date-like type for NSDate proxying.
Args:
type_object: Python type that represents dates/times
Enables automatic conversion between the Python type and NSDate.
"""
def registerPathType(type_object):
"""
Register a path-like type for filesystem path handling.
Args:
type_object: Python type that represents filesystem paths
Enables proper path handling with Objective-C path-related APIs.
"""Comprehensive SIMD vector types for high-performance mathematical operations.
# Integer vectors
simd_int2: type # 2-component integer vector
simd_int3: type # 3-component integer vector
simd_int4: type # 4-component integer vector
simd_uint2: type # 2-component unsigned integer vector
simd_uint3: type # 3-component unsigned integer vector
# Short vectors
simd_short2: type # 2-component short vector
simd_ushort2: type # 2-component unsigned short vector
simd_ushort3: type # 3-component unsigned short vector
simd_ushort4: type # 4-component unsigned short vector
# Character vectors
simd_uchar16: type # 16-component unsigned char vector
# Float vectors
simd_float2: type # 2-component float vector
simd_float3: type # 3-component float vector
simd_float4: type # 4-component float vector
# Double vectors
simd_double2: type # 2-component double vector
simd_double3: type # 3-component double vector
simd_double4: type # 4-component double vector
# Quaternions
simd_quatf: type # Float quaternion
simd_quatd: type # Double quaternion
# Vector aliases (compatible with Metal and other frameworks)
vector_float2: type # Alias for simd_float2
vector_float3: type # Alias for simd_float3
vector_float4: type # Alias for simd_float4
vector_double2: type # 2-component double vector
vector_double3: type # 3-component double vector
vector_double4: type # 4-component double vector
vector_short2: type # 2-component short vector
vector_ushort2: type # 2-component unsigned short vector
vector_ushort3: type # 3-component unsigned short vector
vector_ushort4: type # 4-component unsigned short vector
vector_int2: type # 2-component integer vector
vector_int3: type # 3-component integer vector
vector_int4: type # 4-component integer vector
vector_uint2: type # 2-component unsigned integer vector
vector_uint3: type # 3-component unsigned integer vector
vector_uchar16: type # 16-component unsigned char vectorMatrix types for 3D graphics and mathematical operations.
# Float matrices
matrix_float2x2: type # 2x2 float matrix
matrix_float3x3: type # 3x3 float matrix
matrix_float4x3: type # 4x3 float matrix
matrix_float4x4: type # 4x4 float matrix
simd_float4x4: type # Alias for matrix_float4x4
# Double matrices
matrix_double4x4: type # 4x4 double matrixUsage Examples:
import objc
from objc import (registerListType, registerMappingType, registerSetType,
registerDateType, simd_float3, matrix_float4x4)
# Register custom collection types
class MyCustomList:
def __init__(self):
self.items = []
def append(self, item):
self.items.append(item)
def __len__(self):
return len(self.items)
# Register with bridge for automatic NSMutableArray conversion
registerListType(MyCustomList)
# Register custom mapping type
class MyCustomDict:
def __init__(self):
self.data = {}
def __setitem__(self, key, value):
self.data[key] = value
def __getitem__(self, key):
return self.data[key]
registerMappingType(MyCustomDict)
# Using SIMD types for high-performance operations
position = simd_float3(1.0, 2.0, 3.0) # 3D position vector
# 4x4 transformation matrix for 3D graphics
transform = matrix_float4x4([
[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]
])
# SIMD types work seamlessly with Metal, SceneKit, and other frameworks
# that expect vectorized data typesThe registered types and SIMD support enable seamless integration with:
Install with Tessl CLI
npx tessl i tessl/pypi-pyobjc-core