Python, mmap for in-memory data sharing

Source: Internet
Author: User
Tags tagname

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

import mmapmmap_file = none# #从内存中读取信息, Def read_mmap_info ():         global mmap_file    mmap_file.seek (0)     ## Convert the binary to String     info_str=mmap_file.read (). Translate (none, b ' \x00 '). Decode ()      print (INFO_STR) # #如果内存中没有对应信息, writes the information to memory for the next call to use Def get_mmap_info ():     global mmap_file    # #第二个参数1024是设定的内存大小, units: bytes. If you have more content, you can turn it up a little bit     mmap_file = mmap.mmap ( -1, 1024, access =  Mmap. access_write, tagname =  ' Share_mmap ')     # #读取有效比特数, excluding empty bits      cnt=mmap_file.read_byte ()     if cnt==0:         print ("Load data to memory")         mmap_ File = mmap.mmap (0, 1024, ACCESS =&NBsp;mmap. access_write, tagname =  ' Share_mmap ')         mmap_ File.write (b "This is the test data")     else :         print ("The data is in memory")          read_mmap_info () # #修改内存块中的数据def  RESET_MMP_INFO:    GLOBAL MMAP_ File    mmap_file.seek (0)     mmap_file.write (b ' \x00 ')      mmap_file.write (b "Load data to memory agine") if __name__== "__main__":     get_mmap_info () Description: If you are using a python-brought IDE, re-open this file once the results of running test data are loaded into memory

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>


Python, mmap for in-memory data sharing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.