增加Python中的内存限制? [英] Increasing memory limit in Python?

查看:1108
本文介绍了增加Python中的内存限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在使用一个制作非常长的字典的函数(用于比较DNA字符串),有时我遇到了MemoryError. 有没有办法为Python分配更多的内存,以便它可以一次处理更多的数据?

I am currently using a function making extremely long dictionaries (used to compare DNA strings) and sometimes I'm getting MemoryError. Is there a way to allot more memory to Python so it can deal with more data at once?

推荐答案

Python不会限制程序的内存使用量.它将分配程序所需的内存,直到计算机内存不足为止.您所能做的就是将上限降低到固定的上限.可以使用resource模块来完成,但这不是您想要的.

Python doesn’t limit memory usage on your program. It will allocate as much memory as your program needs until your computer is out of memory. The most you can do is reduce the limit to a fixed upper cap. That can be done with the resource module, but it isn't what you're looking for.

您需要考虑使代码对内存/性能更友好.

You'd need to look at making your code more memory/performance friendly.

这篇关于增加Python中的内存限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆