11

Python mmap: Doing File I/O With Memory Mapping

 2 years ago
source link: https://realpython.com/courses/python-mmap-io/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Python mmap: Doing File I/O With Memory Mapping

The Zen of Python has a lot of wisdom to offer. One especially useful idea is that “There should be one—and preferably only one—obvious way to do it.” Yet there are multiple ways to do most things in Python, and often for good reason. For example, there are multiple ways to read a file in Python, including the rarely used mmap module.

Python’s mmap provides memory-mapped file input and output (I/O). It allows you to take advantage of lower-level operating system functionality to read files as if they were one large string or array. This can provide significant performance improvements in code that requires a lot of file I/O.

In this video course, you’ll learn:

  • What kinds of computer memory exist
  • What problems you can solve with mmap
  • How use memory mapping to read large files faster
  • How to change a portion of a file without rewriting the entire file
  • How to use mmap to share information between multiple processes

Recommend

  • 38
    • www.tuicool.com 5 years ago
    • Cache

    Use Mmap with Care

    When we implemented the git portion of Sublime Merge , we chose to use mmap for reading git object files. This turned out to be considerably more difficult than we had...

  • 33
    • 微信 mp.weixin.qq.com 4 years ago
    • Cache

    浅谈mmap

    女主宣言 作者说:最近在工作中遇到一个mmap使用相关的问题,造成了一定的困惑,于是花了些时间补了下 mmap的功课,在这里分享给大家,错误和不足之处大家多指教。 本篇文章转载自360技术 PS:...

  • 16
    • 微信 mp.weixin.qq.com 4 years ago
    • Cache

    Linux mmap完全剖析

    mmap() 系统调用介绍 mmap() 系统调用能够将文件映射到内存空间,然后可以通过读写内存来读写文件。我们先来看看  mmap() 系统调用的用法吧, mmap() 函数的原型如下...

  • 14
    • www.pengrl.com 4 years ago
    • Cache

    [译] malloc中的系统调用brk和mmap

    阅读本文前你可能已经知道,malloc通过系统调用的方式从操作系统申请内存。事实上,malloc内部是通过系统调用 brk 或

  • 16

    [译] malloc中的系统调用brk和mmap 发表于 2020-03-16 | 分类于 计算机系统| 字数统计: 1.3k阅读本文前你可能已经知道,malloc通过系统调用的...

  • 10

    大家好,跟我学RocketMQ系列并没有结束。随着笔者对RocketMQ的学习与感悟不断深入,我们的旅程也在继续。 本文我将带领读者朋友们一睹RocketMQ实现高性能消息存储的原理,以及它背后的核心Mmap的风采。 RocketMQ消息持久化(消息不丢失)原理...

  • 9
    • man7.org 3 years ago
    • Cache

    mmap(2) - Linux manual page

    Linux manual pagemmap(2) — Linux manual page MMAP(2) Linux Programmer's Manual MMAP(2) NAME         to...

  • 8

    Why is mmap () faster than the sequential IO? advertisements Possible Duplicate: mmap() vs. reading bloc...

  • 5

    Tips For Mind Mapping When Doing Research  A ''mind map'' on the paperResearch is a long-term commitment. It is one thing to simply scroll up and down the web pages and glean from them basic informatio...

  • 6

    User journey map:...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK