{"id":6137,"library":"pyobjc-framework-metalfx","title":"PyObjC Framework MetalFX","description":"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.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","framework","metal","objective-c","graphics"],"install":[{"cmd":"pip install pyobjc-framework-metalfx","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides the core bridge between Python and Objective-C, essential for all PyObjC framework wrappers.","package":"pyobjc-core"}],"imports":[{"note":"Framework wrappers are typically imported directly by their framework name, exposing Objective-C classes, functions, and constants under this module.","symbol":"MetalFX","correct":"import MetalFX"}],"quickstart":{"code":"import Foundation\nimport MetalFX\n\n# Basic import to verify the MetalFX framework bindings are accessible.\nprint(f\"MetalFX module imported: {MetalFX}\")\n\n# Attempt to access a known class from the MetalFX framework\n# (e.g., MTLFXTemporalScaler is a prominent class in MetalFX for temporal upscaling)\n# Note: Actual usage requires a Metal-compatible GPU and specific setup.\ntry:\n    MTLFXTemporalScaler = MetalFX.MTLFXTemporalScaler\n    print(f\"Successfully accessed MetalFX.MTLFXTemporalScaler: {MTLFXTemporalScaler}\")\n    print(f\"Objective-C class name: {MTLFXTemporalScaler.className()}\")\nexcept AttributeError:\n    print(\"Could not find MTLFXTemporalScaler, perhaps due to SDK version or framework availability.\")\n    print(\"Verify your macOS SDK supports the class or check PyObjC documentation for alternatives.\")\n\n# Example showing interaction with a common Foundation class (often used alongside other frameworks)\nNSObject = Foundation.NSObject\nclass MyPythonObject(NSObject):\n    def init(self):\n        self = super().init()\n        if self:\n            print(\"MyPythonObject (subclassing Foundation.NSObject) initialized!\")\n        return self\n\nmy_obj = MyPythonObject.alloc().init()","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer (3.10+ for PyObjC 12.x, 3.9+ for PyObjC 11.x).","message":"PyObjC 12.0 (and thus its framework wrappers) dropped support for Python 3.9. Projects must upgrade to Python 3.10 or later. PyObjC 11.0 dropped Python 3.8 support.","severity":"breaking","affected_versions":"11.0, 12.0+"},{"fix":"Review Objective-C initializer method implementations in Python subclasses to ensure `self = super().init()` patterns correctly handle reference ownership and return values.","message":"PyObjC 11.1 introduced significant changes to how initializer methods (`init` family) are handled, aligning with `clang`'s Automatic Reference Counting documentation. Incorrect handling of `self` reference stealing in initializers can lead to unexpected behavior.","severity":"gotcha","affected_versions":"11.1+"},{"fix":"Avoid using PyObjC in Python 3.13 environments where free-threading (experimental) is enabled, or monitor PyObjC release notes for full free-threading compatibility.","message":"While PyObjC 11.0 introduced experimental support for Python 3.13's free-threading (PEP 703), PyObjC itself does not currently support this experimental feature. Using PyObjC with free-threading enabled in Python 3.13 may lead to instability.","severity":"gotcha","affected_versions":"11.0+"},{"fix":"If implementing `__new__` in a Python subclass of an Objective-C class, ensure `__init__` behavior is compatible with PyObjC's rules or explicitly manage object initialization without relying on `__init__` if using PyObjC's default `__new__`.","message":"In PyObjC 10.3, support for calling `__init__` in Python subclasses when a user-defined `__new__` was present was temporarily dropped, breaking some projects. This was partially reintroduced in 10.3.1, but code relying on PyObjC's provided `__new__` still cannot use `__init__`.","severity":"gotcha","affected_versions":"10.3, 10.3.1+"},{"fix":"Migrate away from the `IMServicePlugIn` framework, as it is no longer available in recent macOS versions or PyObjC bindings.","message":"The `IMServicePlugIn` framework bindings were removed entirely in PyObjC 10.0, as the framework was deprecated in macOS 10.13 and removed in macOS 14. Code relying on these bindings will fail.","severity":"breaking","affected_versions":"10.0+"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}