差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン 次のリビジョン両方とも次のリビジョン | ||
c_cpp:boost:boost_python [2020/08/27 19:39] – [Boost.Python プロジェクト (superfastcode_boost - Python 用 C++ 拡張機能) の作成] ともやん | c_cpp:boost:boost_python [2020/09/11 09:36] – [参考文献] ともやん | ||
---|---|---|---|
行 28: | 行 28: | ||
</ | </ | ||
====== Boost.Python - Boost Python Library ====== | ====== Boost.Python - Boost Python Library ====== | ||
+ | 本家: [[https:// | ||
+ | |||
**Boost Python Library** は、Python と C++ を連携させるためのフレームワークである。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用することなく、C++ クラスの関数やオブジェクトを Python に素早くシームレスに公開できる。\\ | **Boost Python Library** は、Python と C++ を連携させるためのフレームワークである。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用することなく、C++ クラスの関数やオブジェクトを Python に素早くシームレスに公開できる。\\ | ||
行 395: | 行 397: | ||
</ | </ | ||
{{c_cpp: | {{c_cpp: | ||
+ | |||
+ | **ソリューション エクスプローラー** より **PyHelloBoostPython** ソリューションを右クリックして、**[プロパティ]**をクリックする。\\ | ||
+ | **シングル スタートアップ プロジェクト**が **PyHelloBoostPython** であることを確認する。\\ | ||
+ | {{c_cpp: | ||
==== ソリューション内の Python プロジェクトで C++ 拡張機能 プロジェクトを参照する ==== | ==== ソリューション内の Python プロジェクトで C++ 拡張機能 プロジェクトを参照する ==== | ||
行 400: | 行 406: | ||
{{c_cpp: | {{c_cpp: | ||
- | **PyHelloBoostPython** プロジェクトの**[参照]**を右クリックして、**[参照の追加...]**を右クリックする。\\ | + | **PyHelloBoostPython** プロジェクトの**[参照]**を右クリックして、**[参照の追加...]**をクリックする。\\ |
{{c_cpp: | {{c_cpp: | ||
行 406: | 行 412: | ||
{{c_cpp: | {{c_cpp: | ||
- | 以下のように **PyHelloBoostPython** プロジェクトの参照に C++ 拡張機能 プロジェクトが追加されて、検索パス (**x64\Relase**) にビルド出力の ***.pyd** ファイルが配置されるので Python プロジェクトから import することが可能になる。\\ | + | 以下のように **PyHelloBoostPython** プロジェクトの参照に C++ 拡張機能 プロジェクトが追加されて、検索パス (**x64\Release**) にビルド出力の ***.pyd** ファイルが配置されるので Python プロジェクトから |
{{c_cpp: | {{c_cpp: | ||
+ | ==== Python プロジェクトの実行 ==== | ||
+ | Visual Studio の画面で **Ctrl + F5**(デバッグなしで開始) キーを押して実行する。\\ | ||
+ | Python コードと C++ コードの実行速度のベンチマーク結果が表示される。\\ | ||
+ | <WRAP prewrap 100% #result> | ||
+ | <code powershell> | ||
+ | Running benchmarks with COUNT = 500000 x NUM_OF_EXEC = 30 | ||
+ | [tanh(x) for x in d] (Python implementation) took 1.930 seconds | ||
+ | [fast_tanh(x) for x in d] (CPython C++ implementation) took 0.248 seconds | ||
+ | [boost_tanh(x) for x in d] (Boost.Python C++ implementation) took 0.289 seconds | ||
+ | 続行するには何かキーを押してください . . . | ||
+ | </ | ||
+ | </ | ||
===== 参考文献 ===== | ===== 参考文献 ===== | ||
[[https:// | [[https:// | ||
[[http:// | [[http:// | ||
+ | |||
+ | [[http:// | ||
+ | [[https:// | ||
+ | [[https:// | ||