Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
5e32424b
Kaydet (Commit)
5e32424b
authored
Mar 13, 2013
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#17402: avoid shadowing built-in map in mmap examples. Initial patch by Aman Shah.
üst
fda7a8ce
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
mmap.rst
Doc/library/mmap.rst
+12
-12
No files found.
Doc/library/mmap.rst
Dosyayı görüntüle @
5e32424b
...
@@ -114,19 +114,19 @@ memory but does not update the underlying file.
...
@@ -114,19 +114,19 @@ memory but does not update the underlying file.
with open("hello.txt", "r+b") as f:
with open("hello.txt", "r+b") as f:
# memory-map the file, size 0 means whole file
# memory-map the file, size 0 means whole file
m
ap
= mmap.mmap(f.fileno(), 0)
m
m
= mmap.mmap(f.fileno(), 0)
# read content via standard file methods
# read content via standard file methods
print m
ap
.readline() # prints "Hello Python!"
print m
m
.readline() # prints "Hello Python!"
# read content via slice notation
# read content via slice notation
print m
ap
[:5] # prints "Hello"
print m
m
[:5] # prints "Hello"
# update content using slice notation;
# update content using slice notation;
# note that new content must have same size
# note that new content must have same size
m
ap
[6:] = " world!\n"
m
m
[6:] = " world!\n"
# ... and read again using standard file methods
# ... and read again using standard file methods
m
ap
.seek(0)
m
m
.seek(0)
print m
ap
.readline() # prints "Hello world!"
print m
m
.readline() # prints "Hello world!"
# close the map
# close the map
m
ap
.close()
m
m
.close()
The next example demonstrates how to create an anonymous map and exchange
The next example demonstrates how to create an anonymous map and exchange
...
@@ -135,16 +135,16 @@ memory but does not update the underlying file.
...
@@ -135,16 +135,16 @@ memory but does not update the underlying file.
import mmap
import mmap
import os
import os
m
ap
= mmap.mmap(-1, 13)
m
m
= mmap.mmap(-1, 13)
m
ap
.write("Hello world!")
m
m
.write("Hello world!")
pid = os.fork()
pid = os.fork()
if pid == 0: # In a child process
if pid == 0: # In a child process
m
ap
.seek(0)
m
m
.seek(0)
print m
ap
.readline()
print m
m
.readline()
m
ap
.close()
m
m
.close()
Memory-mapped file objects support the following methods:
Memory-mapped file objects support the following methods:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment