Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import mmap
- def mapear_memoria(archivo, acceso=mmap.ACCESS_WRITE):
- tamahnio = os.path.getsize(archivo)
- apertura = os.open(archivo, os.O_RDWR)
- return mmap.mmap(apertura, tamahnio, access=acceso)
- tamahnio = 1000000
- with open('datos', 'wb') as f:
- f.seek(tamahnio - 1)
- f.write(b'\x00')
- m = mapear_memoria('datos')
- print(len(m))
- print(m[0:17])
- m[0:17] =b'Python es genial!'
- m.close()
- with open('datos', 'rb') as f:
- print(f.read(17))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement