Results of 1 - 10 of about 11 for PyModuleDef (0.005 sec.)
- モジュールオブジェクト (module object) 12927
- モジュールオブジェクト (module object) PyTypeObject PyModule_Type 次に属します: Stable ABI . この PyTypeObject のインスタンスは Python のモジュール型を表します。 Python プログラムには types.ModuleType として公開されています。 int PyModule_C
...turn the "state" of the module, that is, a pointer to the block of memory allocated at module creation time, or NULL . See PyModuleDef.m_size . PyModuleDef * PyModule_GetDef ( PyObject * module ) 次に属します: Stable ABI . モジュールが作られる元となった PyM...によって作られていなかった場合は NULL を返します。 エラー時には例外を設定して NULL を返します。 PyErr_Occurred() を使って、 PyModuleDef がない場合と区別してください。 PyObject * PyModule_GetFilenameObject ( PyObject * module ) 戻り値: 新しい参照。 次に属しま...e object, including modules imported from Python code. Modules defined using the C API typically use a module definition , PyModuleDef -- a statically allocated, constant “description" of how a module should be created. The definition is usually used to def... - https://man.mtool.work/python/3.14/c-api/module.html
- 拡張モジュールの定義 10971
- 拡張モジュールの定義 A C extension for CPython is a shared library (for example, a .so file on Linux, .pyd DLL on Windows), which is loadable into the Python process (for example, it is compiled with compatible compiler settings), and which
...en/latest/setuptools.html にあります。 Normally, the initialization function returns a module definition initialized using PyModuleDef_Init() . This allows splitting the creation process into several phases: Before any substantial code is executed, Python c...します。 C++ では、関数を extern "C" として宣言します。 例えば spam というモジュールは、次のように定義します。 static struct PyModuleDef spam_module = { . m_base = PyModuleDef_HEAD_INIT , . m_name = "spam" , ... }; PyMODINIT_FUNC PyInit_spam ( void ) { return...PyModuleDef_Init ( & spam_module ); } It is possible to export multiple modules from a single shared library by defining multiple init... - https://man.mtool.work/python/3.14/c-api/extension-modules.html
- 2. 拡張の型の定義: チュートリアル 10704
- 2. 拡張の型の定義: チュートリアル Python では、組み込みの str 型や list 型のような Python コードから操作できる新しい型を C 拡張モジュールの作者が定義できます。 全ての拡張の型のコードはあるパターンに従うのですが、書き始める前に理解しておくべ
...-1 ; } if ( PyModule_AddObjectRef ( m , "Custom" , ( PyObject * ) & CustomType ) < 0 ) { return -1 ; } return 0 ; } static PyModuleDef_Slot custom_module_slots [] = { { Py_mod_exec , custom_module_exec }, // 静的な型を使う間はこの設定を使う { Py_mod_multipl...e_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED }, { 0 , NULL } }; static PyModuleDef custom_module = { . m_base = PyModuleDef_HEAD_INIT , . m_name = "custom" , . m_doc = "拡張型を作成するサンプルモジュール。..." , . m_size = 0 , . m_slots = custom_module_slots , }; PyMODINIT_FUNC PyInit_custom ( void ) { return PyModuleDef_Init ( & custom_module ); } 一度に理解するにはかなりの量ですが、前の章で見たことのある部分もあるでしょう。 このファイルでは... - https://man.mtool.work/python/3.14/extending/newtypes_tutorial.html
- C API 拡張のフリースレッド対応 8748
- C API 拡張のフリースレッド対応 CPython 3.13 から、 global interpreter lock (GIL) を無効にして実行する free threading という構成がサポートされています。 このドキュメントでは、C API を使う拡張をフリースレッドに対応させる方法を説明します。 C か
...ズ初期化のどちらを使うかによって、2 通りあります。 複数フェーズ初期化 Extensions that use multi-phase initialization (i.e., PyModuleDef_Init() ) should add a Py_mod_gil slot in the module definition. If your extension supports older versions of CPython, you...should guard the slot with a PY_VERSION_HEX check. static struct PyModuleDef_Slot module_slots [] = { ... #if PY_VERSION_HEX >= 0x030D0000 { Py_mod_gil , Py_MOD_GIL_NOT_USED }, #endif { 0 , NULL } };...static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT , . m_slots = module_slots , ... }; 単一フェーズ初期化 Extensions that use single-phas... - https://man.mtool.work/python/3.14/howto/free-threading-extensions.html
- 1. Extending Python with C or C++ 8570
- 1. Extending Python with C or C++ It is quite easy to add new built-in modules to Python, if you know how to program in C. Such extension modules can do two things that can't be done directly in Python: they can implement new built-in objec
...ror" , NULL , NULL ); if ( PyModule_AddObjectRef ( m , "SpamError" , SpamError ) < 0 ) { return -1 ; } return 0 ; } static PyModuleDef_Slot spam_module_slots [] = { { Py_mod_exec , spam_module_exec }, { 0 , NULL } }; static struct PyModuleDef spam_module =...{ . m_base = PyModuleDef_HEAD_INIT , . m_name = "spam" , . m_size = 0 , // 非負の値 . m_slots = spam_module_slots , }; PyMODINIT_FUNC PyInit_spam (...void ) { return PyModuleDef_Init ( & spam_module ); } 例外オブジェクトの Python での名前は spam.error であることに注意してください。 PyErr_NewExceptio... - https://man.mtool.work/python/3.14/extending/extending.html
- C API Stability 8304
- C API Stability 特記のない限り、Python の C API には後方互換性ポリシー PEP 387 が適用されます。 変更の大半はソース互換性を保ちます (通常は新しい API の追加だけを行います)。 既存 API の変更や削除は、非推奨の期間を経た後、または重大な問題を修
...yView_FromMemory() PyMemoryView_FromObject() PyMemoryView_GetContiguous() PyMemoryView_Type PyMethodDef PyMethodDescr_Type PyModuleDef PyModuleDef_Base PyModuleDef_Init() PyModuleDef_Slot PyModuleDef_Type PyModule_Add() PyModule_AddFunctions() PyModule_AddI... - https://man.mtool.work/python/3.14/c-api/stable.html
- 拡張モジュールを分離する 7948
- 拡張モジュールを分離する 概要 従来、Python 拡張モジュールの状態は、プロセス全体をスコープとする C の static 変数に保持されていました。 このドキュメントでは、プロセスごとの状態が抱える問題と、より安全な方法であるモジュールごとの状態について説
...拡張モジュールの複数フェーズ初期化 を使います。 これはモジュールが複数のインタープリタを正しくサポートすることを示します。 PyModuleDef.m_size に正の数を設定すると、そのバイト数のモジュール専用の記憶領域を確保できます。 通常は、モジュールの C レベルの状態をす...す。 モジュールの初期化の例はファイルの末尾にあります。 対応しない場合: プロセスごとに一つのモジュールオブジェクトに制限する PyModuleDef.m_size が非負であることは、モジュールが複数のインタープリタを正しくサポートすることを示します。 まだ対応していない場合は、...once per process" ); return -1 ; } loaded = 1 ; PyMutex_Unlock ( & modinit_mutex ); // ... 残りの初期化処理 } モジュールの PyModuleDef.m_clear 関数で将来の再初期化に備えられる場合は、そこで loaded フラグをクリアしてください。 この場合、複数のインスタンスの... - https://man.mtool.work/python/3.14/howto/isolating-extensions.html
- 1. 他のアプリケーションへの Python の埋め込み 7859
- 1. 他のアプリケーションへの Python の埋め込み 前章では、 Python を拡張する方法、すなわち C 関数のライブラリを Python に結びつけて機能を拡張する方法について述べました。同じようなことを別の方法でも実行できます: それは、自分の C/C++ アプリケー
..." , emb_numargs , METH_VARARGS , "プロセスが受け取った引数の数を返します。" }, { NULL , NULL , 0 , NULL } }; static struct PyModuleDef emb_module = { . m_base = PyModuleDef_HEAD_INIT , . m_name = "emb" , . m_size = 0 , . m_methods = emb_module_methods , };...static PyObject * PyInit_emb ( void ) { return PyModuleDef_Init ( & emb_module ); } 上のコードを main() 関数のすぐ上に挿入します。また、以下の二つの文を Py_Initialize() の呼び出しの... - https://man.mtool.work/python/3.14/extending/embedding.html
- 型オブジェクト 7415
- 型オブジェクト type PyTypeObject 次に属します: Limited API (不透明な構造体として). 組み込み型を記述する際に用いられる、オブジェクトを表す C 構造体です。 PyTypeObject PyType_Type 次に属します: Stable ABI . 型オブジェクト自身の型オブジェクトで
...は、例外を設定せずに NULL を返します。 Added in version 3.9. PyObject * PyType_GetModuleByDef ( PyTypeObject * type , struct PyModuleDef * def ) 戻り値: 借用参照。 次に属します: Stable ABI (バージョン 3.13 より). Find the first superclass whose module was cre...ated from the given PyModuleDef def , and return that module. モジュールが見つからない場合は、 TypeError を送出して NULL を返します。 この関数は、 tp_init... - https://man.mtool.work/python/3.14/c-api/type.html
- 共通のオブジェクト構造体 (common object structure) 7148
- 共通のオブジェクト構造体 (common object structure) Python のオブジェクト型の定義には、多数の構造体が使われます。 この節では、それらの構造体と使い方を説明します。 基本のオブジェクト型とマクロ すべての Python オブジェクトは、メモリ上の表現の先
...属します: Stable ABI . func の「self」オブジェクトを取得します。 これは PyCFunction の第 1 引数に渡されるオブジェクトです。 PyModuleDef 上の PyMethodDef を介して作成した C 関数オブジェクトでは、作成されたモジュールオブジェクトになります。 func が C 関数オブジ... - https://man.mtool.work/python/3.14/c-api/structures.html