V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
omg21
V2EX  ›  Python

python 有没有暂存数据的地方?

  •  
  •   omg21 · 2016-10-25 19:52:41 +08:00 · 2705 次点击
    这是一个创建于 2742 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我之前把程序运行的步骤过程都输出到文件中,一步一步的存进去,每一步都记录下来。
    现在考虑这可能会损害硬盘的读取寿命,我在想, python 有没有一个能够暂存数据的地方,我想用列表来记录,最后再把列表输出到文件中。除了这样,还有没有其他的方法?
    8 条回复    2016-10-26 15:28:26 +08:00
    dsg001
        1
    dsg001  
       2016-10-25 19:58:50 +08:00
    标准库 tempfile

    伤硬盘这个说法已经好多年没见了,当年流传最光的就是 bt 、迅雷伤硬盘
    Mutoo
        2
    Mutoo  
       2016-10-25 20:01:33 +08:00
    https://docs.python.org/2/library/io.html
    并不是你每次 write 都会进行文件 IO , python 本身就有缓存。超过缓存的时候才会进行一次实际的 IO 。
    Trim21
        3
    Trim21  
       2016-10-25 20:09:46 +08:00 via Android
    SQLite 也可以创建内存数据库。。
    btjoker
        4
    btjoker  
       2016-10-25 20:37:04 +08:00
    write 后不是马上写入硬盘的,有个缓冲区
    关闭文件或使用 flush 方法才会写入硬盘
    loading
        5
    loading  
       2016-10-25 20:51:13 +08:00 via Android
    sqlite ram
    zhuangzhuang1988
        6
    zhuangzhuang1988  
       2016-10-25 21:07:59 +08:00
    threadlocal
    lxy
        7
    lxy  
       2016-10-25 21:43:23 +08:00
    linux 不是自带缓存吗
    misaka19000
        8
    misaka19000  
       2016-10-26 15:28:26 +08:00
    直接放在内存里面不行吗?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3013 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:21 · PVG 22:21 · LAX 07:21 · JFK 10:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.