2017年7月12日 星期三

Boost.Python 小記

建構子

沒有建構子的 class 要在宣告 mapping 的時候給建構子的 prototype

std::vector<>

跟 python 對接的陣列,要用  boost::python::list 

Overloading function

使用「明確轉型」來指定特定的 overloading 版本

import_array()

使用 numpy 要  import_array()  ,不然執行期用  PyArray_SimpleNewFromData()  建立陣列的時候會 segmentation fault。特別注意的是  import_array()  其實是一個陣列,他會去初始化一個 static variable 叫做  PyArray_APIPyArray_API  是一個 compile unit static variable,所以每一個 .cpp 檔自己都要  import_array() ,但重複 import 又會錯,所以呼叫前要先檢查  PyArray_API  這個變數是否已經被設定。

if (PyArray_API == NULL) {
    import_array();
}


1 則留言:

  1. Pretty much every fantasy about US slots is true of UK fruit machines. And while the reason is simplified, that's really how they calculate return to participant . Those AGS Must Hits essentially use 카지노 사이트 a weighted reel discover out} after they hit, and it's extraordinarily heavily weighted to the end of the climb. When a bonus round happens, it ALWAYS appears the bonus round happens 2 or 3 extra times in a brief interval after the first bonus round, then no bonuses for ages - and lots of cash gone. Slot gamers are said to either win or lose; they never "possibly win" or "possibly lose," or never "virtually win." There are many other games available at Super Slots, ensuring you never get bored when gambling here.

    回覆刪除