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
fe1c471c
Kaydet (Commit)
fe1c471c
authored
Mar 13, 2013
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
#17402: merge with 3.3.
üst
405952f1
a142a343
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
mmap.rst
Doc/library/mmap.rst
+14
-14
No files found.
Doc/library/mmap.rst
Dosyayı görüntüle @
fe1c471c
...
...
@@ -106,19 +106,19 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
with open("hello.txt", "r+b") as f:
# 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
print(m
ap
.readline()) # prints b"Hello Python!\n"
print(m
m
.readline()) # prints b"Hello Python!\n"
# read content via slice notation
print(m
ap
[:5]) # prints b"Hello"
print(m
m
[:5]) # prints b"Hello"
# update content using slice notation;
# note that new content must have same size
m
ap
[6:] = b" world!\n"
m
m
[6:] = b" world!\n"
# ... and read again using standard file methods
m
ap
.seek(0)
print(m
ap
.readline()) # prints b"Hello world!\n"
m
m
.seek(0)
print(m
m
.readline()) # prints b"Hello world!\n"
# close the map
m
ap
.close()
m
m
.close()
:class:`mmap` can also be used as a context manager in a :keyword:`with`
...
...
@@ -126,8 +126,8 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
import mmap
with mmap.mmap(-1, 13) as m
ap
:
m
ap
.write("Hello world!")
with mmap.mmap(-1, 13) as m
m
:
m
m
.write("Hello world!")
.. versionadded:: 3.2
Context manager support.
...
...
@@ -139,16 +139,16 @@ To map anonymous memory, -1 should be passed as the fileno along with the length
import mmap
import os
m
ap
= mmap.mmap(-1, 13)
m
ap
.write(b"Hello world!")
m
m
= mmap.mmap(-1, 13)
m
m
.write(b"Hello world!")
pid = os.fork()
if pid == 0: # In a child process
m
ap
.seek(0)
print(m
ap
.readline())
m
m
.seek(0)
print(m
m
.readline())
m
ap
.close()
m
m
.close()
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