PyObjC Framework MetalFX

12.1 · active · verified Tue Apr 14

PyObjC Framework MetalFX provides Python wrappers for Apple's MetalFX framework on macOS. It enables Python developers to interact with MetalFX APIs, which are part of Apple's graphics technologies for upscaling, anti-aliasing, and other visual effects. The library is part of the broader PyObjC project, which bridges Python and Objective-C, offering bindings to most macOS Objective-C frameworks. Version 12.1 was released in November 2025 and the project maintains an active release cadence, typically aligning with macOS SDK updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `MetalFX` framework bindings and access an Objective-C class through PyObjC. It also includes a common pattern for subclassing a `Foundation.NSObject` in Python, illustrating the core interoperability.

import Foundation
import MetalFX

# Basic import to verify the MetalFX framework bindings are accessible.
print(f"MetalFX module imported: {MetalFX}")

# Attempt to access a known class from the MetalFX framework
# (e.g., MTLFXTemporalScaler is a prominent class in MetalFX for temporal upscaling)
# Note: Actual usage requires a Metal-compatible GPU and specific setup.
try:
    MTLFXTemporalScaler = MetalFX.MTLFXTemporalScaler
    print(f"Successfully accessed MetalFX.MTLFXTemporalScaler: {MTLFXTemporalScaler}")
    print(f"Objective-C class name: {MTLFXTemporalScaler.className()}")
except AttributeError:
    print("Could not find MTLFXTemporalScaler, perhaps due to SDK version or framework availability.")
    print("Verify your macOS SDK supports the class or check PyObjC documentation for alternatives.")

# Example showing interaction with a common Foundation class (often used alongside other frameworks)
NSObject = Foundation.NSObject
class MyPythonObject(NSObject):
    def init(self):
        self = super().init()
        if self:
            print("MyPythonObject (subclassing Foundation.NSObject) initialized!")
        return self

my_obj = MyPythonObject.alloc().init()

view raw JSON →