orkcore-python

Convert C++ and Python types with pybind11 and nanobind adapters.

35|16|Updated Feb 10, 2013
One-click install
npx skills add https://github.com/tweakoz/orkid --skill orkcore-python
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: orkcore-python
Source: https://github.com/tweakoz/orkid/tree/main/.claude/skills/orkcore-python
Command: npx skills add https://github.com/tweakoz/orkid --skill orkcore-python

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Orkid's C++ engine exposes a rich but complex Python binding surface that requires consistent type conversion, safe callback handling across threads and interpreters, and repeatable module initialization patterns so developers can reliably interact with engine objects from Python.

Core Features & Use Cases

  • Type Codec: Centralized encode/decode layer for converting between Orkid C++ types and Python objects, and registering custom pointer codecs.
  • GIL-Safe Wrapper: A gil_safe_pyobj construct for storing Python callbacks in C++ and ensuring the GIL is acquired on destruction and invocation.
  • Dual Adapter System: Support for both pybind11 (main interpreter) and nanobind (subinterpreters) via adapter templates and shared binding code.
  • VarMap and Bindings: Dynamic attribute access and common bindings for math, crc strings, and VarMap semantics.
  • Factory & Callback Patterns: Standard wfactory/uifactory statics for UI widget creation and recommended callback binding patterns for safety.
  • Use Cases: Bind a new engine class to Python with proper type codec registration, expose UI widgets with wfactory/uifactory, and store long-lived Python callbacks safely from non-GIL threads.

Quick Start

Show me how to implement a pybind11 module initializer that registers a custom type codec, binds a widget with wfactory and uifactory statics, and uses gil_safe_pyobj for thread-safe callbacks.

Frequently Asked Questions about orkcore-python

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I store Python callbacks in C++ and ensure GIL safety across threads?

To ensure GIL safety for Python callbacks stored in C++, use the gil_safe_pyobj construct, which automatically acquires the Global Interpreter Lock upon destruction and invocation from non-GIL threads.

How do I convert between C++ and Python types using a type codec?

To convert between C++ and Python types, register a custom type codec within the centralized encode and decode layer. This system handles standard type conversions and allows registering custom pointer codecs for engine objects.

Does this Python binding system support both pybind11 and nanobind adapters?

Yes, the dual adapter system supports both pybind11 for the main interpreter and nanobind for subinterpreters. It uses adapter templates and shared binding code to maintain consistent module initialization across both frameworks.

How do I expose UI widgets to Python using factory patterns?

To expose UI widgets to Python, use the standard wfactory and uifactory statics for widget creation. These factory patterns provide a consistent binding mechanism for UI widget generation and callback integration.

What is the best way to release the GIL for blocking operations in Python bindings?

To release the GIL for blocking operations, implement unmanaged pointer wrappers that safely detach from the Python interpreter. This allows long-running C++ operations to execute without blocking the Python thread.

Can I use VarMap bindings for dynamic attribute access in Python?

Yes, VarMap bindings provide dynamic attribute access in Python, supporting common bindings for math operations, crc strings, and VarMap semantics to interact dynamically with engine objects.