c_cpp:boost:boost_python

差分

このページの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:38] – [参考文献] ともやん
行 28: 行 28:
 </html> </html>
 ====== Boost.Python - Boost Python Library ====== ====== Boost.Python - Boost Python Library ======
 +本家: [[https://www.boost.org/doc/libs/release/libs/python/|Boost.Python - Boost Library Documentation]]\\
 +
 **Boost Python Library** は、Python と C++ を連携させるためのフレームワークである。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用することなく、C++ クラスの関数やオブジェクトを Python に素早くシームレスに公開できる。\\ **Boost Python Library** は、Python と C++ を連携させるためのフレームワークである。Dave Abrahams の C++ コンパイラだけで、特別なツールを使用することなく、C++ クラスの関数やオブジェクトを Python に素早くシームレスに公開できる。\\
  
行 395: 行 397:
 </WRAP>  </WRAP> 
 {{c_cpp:visualstudio2019_boost.python_026.png?600|Visual Studio 2019 Boost.Python 026}}\\ {{c_cpp:visualstudio2019_boost.python_026.png?600|Visual Studio 2019 Boost.Python 026}}\\
 +
 +**ソリューション エクスプローラー** より **PyHelloBoostPython** ソリューションを右クリックして、**[プロパティ]**をクリックする。\\
 +**シングル スタートアップ プロジェクト**が **PyHelloBoostPython** であることを確認する。\\
 +{{c_cpp:visualstudio2019_boost.python_032.png?600|Visual Studio 2019 Boost.Python 032}}\\
  
 ==== ソリューション内の Python プロジェクトで C++ 拡張機能 プロジェクトを参照する ==== ==== ソリューション内の Python プロジェクトで C++ 拡張機能 プロジェクトを参照する ====
行 400: 行 406:
 {{c_cpp:visualstudio2019_boost.python_027.png?610|Visual Studio 2019 Boost.Python 027}}\\ {{c_cpp:visualstudio2019_boost.python_027.png?610|Visual Studio 2019 Boost.Python 027}}\\
  
-**PyHelloBoostPython** プロジェクトの**[参照]**を右クリックして、**[参照の追加...]**をクリックする。\\+**PyHelloBoostPython** プロジェクトの**[参照]**を右クリックして、**[参照の追加...]**をクリックする。\\
 {{c_cpp:visualstudio2019_boost.python_028.png?250|Visual Studio 2019 Boost.Python 028}}\\ {{c_cpp:visualstudio2019_boost.python_028.png?250|Visual Studio 2019 Boost.Python 028}}\\
  
行 406: 行 412:
 {{c_cpp:visualstudio2019_boost.python_029.png?600|Visual Studio 2019 Boost.Python 029}}\\ {{c_cpp:visualstudio2019_boost.python_029.png?600|Visual Studio 2019 Boost.Python 029}}\\
  
-以下のように **PyHelloBoostPython** プロジェクトの参照に C++ 拡張機能 プロジェクトが追加されて、検索パス (**x64\Relase**) にビルド出力の ***.pyd** ファイルが配置されるので Python プロジェクトから import することが可能になる。\\ +以下のように **PyHelloBoostPython** プロジェクトの参照に C++ 拡張機能 プロジェクトが追加されて、検索パス (**x64\Release**) にビルド出力の ***.pyd** ファイルが配置されるので Python プロジェクトから **import** することが可能になる。\\ 
 {{c_cpp:visualstudio2019_boost.python_030.png?250|Visual Studio 2019 Boost.Python 030}}\\ {{c_cpp:visualstudio2019_boost.python_030.png?250|Visual Studio 2019 Boost.Python 030}}\\
  
 +==== 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
 +続行するには何かキーを押してください . . .
 +</code>
 +</WRAP>
  
 ===== 参考文献 ===== ===== 参考文献 =====
 [[https://docs.microsoft.com/ja-jp/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2019|Python 用の C++ 拡張機能の記述 - Visual Studio | Microsoft Docs]]\\ [[https://docs.microsoft.com/ja-jp/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2019|Python 用の C++ 拡張機能の記述 - Visual Studio | Microsoft Docs]]\\
 [[http://moriyoshi.hatenablog.com/entry/20091214/1260779899|Boost.Python の機能をざっと紹介してみる - moriyoshiの日記]]\\ [[http://moriyoshi.hatenablog.com/entry/20091214/1260779899|Boost.Python の機能をざっと紹介してみる - moriyoshiの日記]]\\
 +
 +[[http://alpha.osdn.jp/devel/boost.python_ja.pdf|Boost.Python - Alpha]]\\
 +[[https://qiita.com/maiueo/items/b2093ba78cde988bb111|ctypesの変数についてのメモ - Qiita]]\\
 +[[https://docs.python.org/ja/3/library/ctypes.html|ctypes --- Pythonのための外部関数ライブラリ — Python 3.8.6rc1 ドキュメント]]\\
 +[[https://stackoverflow.com/questions/16105539/boost-python-custom-converter|c++ - Boost.Python custom converter - Stack Overflow]]\\
  
  • c_cpp/boost/boost_python.txt
  • 最終更新: 2021/07/05 01:59
  • by ともやん