{"id":6142,"library":"pyobjc-framework-mlcompute","title":"PyObjC MLCompute Framework","description":"PyObjC-framework-MLCompute provides Python wrappers for Apple's MLCompute framework on macOS, enabling Python applications to leverage GPU acceleration for machine learning tasks. It is part of the larger PyObjC project, currently at version 12.1, with releases typically tied to macOS SDK updates and Python version support.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","objc","bindings","ml","gpu","apple"],"install":[{"cmd":"pip install pyobjc-framework-mlcompute","lang":"bash","label":"Install specific framework"},{"cmd":"pip install pyobjc","lang":"bash","label":"Install all PyObjC frameworks (including MLCompute)"}],"dependencies":[{"reason":"Core PyObjC bridge functionality","package":"pyobjc-core"}],"imports":[{"symbol":"MLCDevice","correct":"from MLCompute import MLCDevice"},{"symbol":"MLCGraph","correct":"from MLCompute import MLCGraph"}],"quickstart":{"code":"from MLCompute import MLCDevice, MLCDeviceTypeCPU, MLCDeviceTypeGPU\n\ndef quickstart_mlcompute():\n    # Get the default CPU device\n    cpu_device = MLCDevice.cpuDevice()\n    print(f\"CPU Device: {cpu_device.description()} (Type: {cpu_device.deviceType()})\")\n\n    # Get the default GPU device if available\n    gpu_device = MLCDevice.gpuDevice()\n    if gpu_device:\n        print(f\"GPU Device: {gpu_device.description()} (Type: {gpu_device.deviceType()})\")\n    else:\n        print(\"No GPU device found or MLCompute is running on a Mac without a Metal GPU.\")\n\n    # Get a device of any type (prefers GPU if available)\n    any_device = MLCDevice.deviceWithAnyType()\n    print(f\"Any Device: {any_device.description()} (Type: {any_device.deviceType()})\")\n\nquickstart_mlcompute()","lang":"python","description":"Demonstrates how to import MLCompute classes and query available CPU and GPU devices. MLCompute provides classes like MLCDevice and MLCGraph for building and executing machine learning models using Apple's Metal Performance Shaders."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or later.","message":"PyObjC 12.0 and later dropped support for Python 3.9. Attempting to install or run on Python 3.9 will result in errors.","severity":"breaking","affected_versions":">=12.0"},{"fix":"Upgrade your Python environment to 3.9 or later (for PyObjC < 12.0) or 3.10 or later (for PyObjC >= 12.0).","message":"PyObjC 11.0 and later dropped support for Python 3.8. Attempting to install or run on Python 3.8 will result in errors.","severity":"breaking","affected_versions":">=11.0"},{"fix":"Refactor code to use alternative macOS APIs or pin PyObjC to a version less than 10.0 if this framework is essential for legacy applications.","message":"The `IMServicePlugIn` framework bindings were entirely removed in PyObjC 10.0 as the framework was deprecated by Apple in macOS 10.13 and completely removed in macOS 14.","severity":"breaking","affected_versions":">=10.0"},{"fix":"Most Python code should not be directly affected. However, low-level Objective-C integrations or code relying on specific reference counting behavior might require review. Consult the PyObjC 11.1 release notes for details.","message":"From PyObjC 11.1, the core bridge's behavior for initializer methods (those in the 'init' family) was updated to align with Clang's Automatic Reference Counting (ARC) documentation. Init methods now correctly model stealing a reference to `self` and returning a new one.","severity":"gotcha","affected_versions":">=11.1"},{"fix":"If implementing `__new__` in a Python subclass, carefully manage initialization logic. Refer to the PyObjC 10.3 and 10.3.1 release notes for precise behavior and workarounds.","message":"PyObjC versions 10.3 and later introduced specific limitations regarding the interaction between `__init__` and `__new__` in custom Python subclasses of Objective-C classes. While 10.3.1 partially re-enabled `__init__` for user-implemented `__new__` methods, code using PyObjC's provided `__new__` still cannot use `__init__`.","severity":"gotcha","affected_versions":">=10.3"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}