提交 0882b46a authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Get more directly the size of void*, long int

上级 445c105a
...@@ -9,6 +9,7 @@ import platform ...@@ -9,6 +9,7 @@ import platform
import shutil import shutil
import stat import stat
import StringIO import StringIO
import struct
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
...@@ -37,8 +38,9 @@ def local_bitwidth(): ...@@ -37,8 +38,9 @@ def local_bitwidth():
""" """
# Note that according to Python documentation, `platform.architecture()` is # Note that according to Python documentation, `platform.architecture()` is
# not reliable on OS X with universal binaries. # not reliable on OS X with universal binaries.
maxsize = sys.maxsize # Also, sys.maxsize does not exist in Python < 2.6.
return len('%x' % maxsize) * 4 # 'P' denotes a void*, and the size is expressed in bytes.
return struct.calcsize('P') * 8
def python_int_bitwidth(): def python_int_bitwidth():
""" """
...@@ -46,8 +48,8 @@ def python_int_bitwidth(): ...@@ -46,8 +48,8 @@ def python_int_bitwidth():
Note that it can be different from the size of a memory pointer. Note that it can be different from the size of a memory pointer.
""" """
maxint = sys.maxint # 'l' denotes a C long int, and the size is expressed in bytes.
return len('%x' % maxint) * 4 return struct.calcsize('l') * 8
_logger=logging.getLogger("theano.gof.cmodule") _logger=logging.getLogger("theano.gof.cmodule")
_logger.setLevel(logging.WARNING) _logger.setLevel(logging.WARNING)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论