I’ve noticed that whenever any integer surpasses 2^31-1 my number heavy code suffers a large slowdown, despite the fact I’m using a 64 bit build of Python on a 64bit version of Windows. This seems to be true on Python 2.7 and Python 3. I’ve read that Windows made their longs to be 32 bits, but that doesn’t suggest to me it is impossible to use 64 bit numbers.

Is there a way to use 64 bit integers either though a class or module or even a different build of Python?

解决方案

I'm not aware of any Windows build that uses a 64-bit native type for int with Python 2.7. All C compilers will use long to refer to a 32 bit type. Changing Python to use long long for the internal representation of int would likely break extension modules.

On Python 3.x, the only integer type is the arbitrary precision type (known as long under Python 2.x). On 64-bit systems, the arbitrary precision type works in chunks of 2^30 bits. On 32-bit systems, the arbitrary precision type works in chunks of 2^15 bits. The values 15 and 30 would be difficult to change.

For external libraries, I maintain the gmpy2 library. It provides access to the arbitrary precision GMP/MPIR library. The gmpy2.mpz integer type is usually more efficient once numbers reach ~128 bits in length. YMMV.

python3中的int类型占64位,有没有什么办法来强制Python来使用64位整数的Windows?相关推荐

  1. python3中的int类型占64位_在windows 10 64位计算机中,默认情况下,numpy数组数据类型将以int32形式出现...

    最初的海报Prana问了一个非常好的问题."为什么在64位计算机上,整数默认设置为32位?"在 据我所知,简短的回答是:"因为它的设计是错误的". 显然,64位 ...

  2. 为什么java中的int类型范围是-2的31次方到2的31次方减一?

    在java基础类型中,int类型占四个字节,而每个字节在内存中占8位(8byte),所以可以使用共4X8=32个位数来存储该类型,也就是四个八位的二进制数,所以有了以下说法 在计算机中,它的二级制表示 ...

  3. int 几个字节 python_Python中一个int类型占了几个字节

    Python中一个int类型占了几个字节 发布时间:2020-07-17 11:36:34 来源:亿速云 阅读:117 作者:清晨 小编给大家分享一下Python中一个int类型占了几个字节,希望大家 ...

  4. 如何形象地理解 Python 中的 int 类型是任意精度这一概念?

    什么,Python 有类型吗?当然有,只是不需显示的声明而已,大概也涉及类型推导机制吧. Python 基本数据类型 >>> a = 10 >>> type(a) ...

  5. 刨根问底:C++中宽字符类型(wchar_t)的编码一定是Unicode?长度一定是16位?

    转发的:https://www.ituring.com.cn/article/111027的文章 刨根问底:C++中宽字符类型(wchar_t)的编码一定是Unicode?长度一定是16位? cons ...

  6. C++中的string 类型占几个字节

    C++中的string 类型占几个字节 一:先看一道面面试题: 题目是要求输出:TrendMicroSoftUSCN 然后要求修改程序,使程序能输出以上结果.代码如下: #include <io ...

  7. python定义一个int_python中定义int类型的方法

    python中定义int类型的方法 发布时间:2020-07-27 11:40:21 来源:亿速云 阅读:106 作者:清晨 这篇文章主要介绍python中定义int类型的方法,文中介绍的非常详细,具 ...

  8. c语言sqlite3写数据类型,在sqlite数据库中,int类型不等于integer数据类型

    在sqlite数据库中,int类型不等于integer数据类型 这些天一直在忙销售管理软件易卖通客户端的程序编写,由于需要采用本地数据缓存机制来提高程序的数据访问效率,所以需要在客户端使用一个小巧的本 ...

  9. mysql数据库中的int类型_mysql数据类型

    mysql数据类型-int int 的有符号和无符号的区别 有符号的int可以插入负值,无符号的int不可以插入负值 整型的每一种都分无符号(unsigned)和有符号(signed)两种类型(flo ...

最新文章

  1. ps aux|grep
  2. 一文读懂机器学习中的正则化
  3. K8S部署工具:KubeOperator安装部署
  4. const关键字的作用?
  5. 使用cdev_add注册字符设备
  6. 15款提高工作效率的工具分享
  7. matlab中文帮助_拿走不谢,simulink,stateflow,ecoder帮助手册中英对照版首发
  8. 如何在C#中实现图片缩放
  9. Screen命令让Linux shell在后台运行
  10. mysql -d -e_mysql常用函数
  11. php 抽象类 接口 区别,php中接口、抽象类以及接口和抽象类区别详解
  12. openfire源码解读--用户登录
  13. Ubuntu18.04版本安装ssh及连接ssh的常见问题
  14. 戴尔计算机恢复,DELL计算机恢复镜像问题(已解决)
  15. 【学习笔记】状态机编程
  16. OpenGL纹理叠加基础知识
  17. python练习54:取一个整数a从右端开始的4〜7位
  18. 数绵羊(矩阵快速幂)
  19. 王者荣耀是用什么编程语言开发的?
  20. 用Python写了一个不起床让你后悔的闹钟

热门文章

  1. 纪·阿晶的首次AWS之行!
  2. 刚刚,Python内幕被爆出!老码农:没控制住,心态已崩!
  3. iis设置服务器文件权限设置,iis7如何配置写入权限以上传文件---急急急
  4. Mybatis-plus 大数据量数据流式查询通用接口
  5. java.lang.NoClassDefFoundError: org/springframework/core/ErrorCoded
  6. 软件设计师 - 计算机组成体系结构 -
  7. JavaScript-严格检查模式
  8. Java-得到 Class 类的几种方式
  9. 邮件格式转换html,HTML邮件模板 - lenglingx的个人页面 - OSCHINA - 中文开源技术交流社区...
  10. php dom 换行,PHP DOM XML不会在标记之后打印掉换行符