3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PythonとCythonのdtypeについて

Posted at

pythonとcythonのdtypeがごちゃごちゃになったので、整理した。

背景

pythonのdtypeで例えばfloat64などがあるが、cythonだとfloat64_tなどが使われる。これらの違いは何か。同じように使ってよいか。

float64_tは何なのか

まず、

import numpy as np
cimport numpy as np

とすると、最初の行でnumpy moduleをimportし、次の行でnumpy.pxdを単にincludeする。
cythonのインストールフォルダーを見ると、たしかにnumpy.pxdがあり、float64_t

ctypedef double       npy_float64
ctypedef npy_float64    float64_t

と定義されている。

結論

float64_t ≠ float64であり、float64_t = doubleだった。

参考

3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?