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
12d31e2e
Kaydet (Commit)
12d31e2e
authored
Şub 13, 2003
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Try to doc the new pickle details being implemented as part of PEP 307.
Needs review.
üst
bb184414
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
7 deletions
+63
-7
libpickle.tex
Doc/lib/libpickle.tex
+63
-7
No files found.
Doc/lib/libpickle.tex
Dosyayı görüntüle @
12d31e2e
...
...
@@ -126,10 +126,35 @@ some other characteristics of \module{pickle}'s representation) is that
for debugging or recovery purposes it is possible for a human to read
the pickled file with a standard text editor.
There are currently 3 different protocols which can be used for pickling.
\begin{itemize}
\item
Protocol version 0 is the original ASCII protocol and is backwards
compatible with earlier versions of Python.
\item
Protocol version 1 is the old binary format which is also compatible
with earlier versions of Python.
\item
Protocol version 2 was introduced in Python 2.3. It provides
much more efficient pickling of new-style classes.
\end{itemize}
Refer to PEP 307 for more information.
If a
\var
{
protocol
}
is not specified, protocol 0 is used.
If
\var
{
protocol
}
is specified as a negative value,
the highest protocol version will be used.
\versionchanged
[The
\var
{
bin
}
parameter is deprecated and only provided
for backwards compatibility. You should use the
\var
{
protocol
}
parameter instead]
{
2.3
}
A binary format, which is slightly more efficient, can be chosen by
specifying a true value for the
\var
{
bin
}
argument to the
\class
{
Pickler
}
constructor or the
\function
{
dump()
}
and
\function
{
dumps()
}
functions.
functions.
A
\var
{
protocol
}
version >= 1 implies use of a binary format.
\subsection
{
Usage
}
...
...
@@ -139,10 +164,20 @@ stream, you first create an unpickler, then you call the unpickler's
\method
{
load()
}
method. The
\module
{
pickle
}
module provides the
following functions to make this process more convenient:
\begin{funcdesc}
{
dump
}{
object, file
\optional
{
,
bin
}}
\begin{funcdesc}
{
dump
}{
object, file
\optional
{
,
protocol
\optional
{
, bin
}
}}
Write a pickled representation of
\var
{
object
}
to the open file object
\var
{
file
}
. This is equivalent to
\code
{
Pickler(
\var
{
file
}
,
\var
{
bin
}
).dump(
\var
{
object
}
)
}
.
\code
{
Pickler(
\var
{
file
}
,
\var
{
protocol
}
,
\var
{
bin
}
).dump(
\var
{
object
}
)
}
.
If the
\var
{
protocol
}
parameter is ommitted, protocol 0 is used.
If
\var
{
protocol
}
is specified as a negative value,
the highest protocol version will be used.
\versionchanged
[The
\var
{
protocol
}
parameter was added.
The
\var
{
bin
}
parameter is deprecated and only provided
for backwards compatibility. You should use the
\var
{
protocol
}
parameter instead]
{
2.3
}
If the optional
\var
{
bin
}
argument is true, the binary pickle format
is used; otherwise the (less efficient) text pickle format is used
(for backwards compatibility, this is the default).
...
...
@@ -169,9 +204,20 @@ This function automatically determines whether the data stream was
written in binary mode or not.
\end{funcdesc}
\begin{funcdesc}
{
dumps
}{
object
\optional
{
,
bin
}}
\begin{funcdesc}
{
dumps
}{
object
\optional
{
,
protocol
\optional
{
, bin
}
}}
Return the pickled representation of the object as a string, instead
of writing it to a file. If the optional
\var
{
bin
}
argument is
of writing it to a file.
If the
\var
{
protocol
}
parameter is ommitted, protocol 0 is used.
If
\var
{
protocol
}
is specified as a negative value,
the highest protocol version will be used.
\versionchanged
[The
\var
{
protocol
}
parameter was added.
The
\var
{
bin
}
parameter is deprecated and only provided
for backwards compatibility. You should use the
\var
{
protocol
}
parameter instead]
{
2.3
}
If the optional
\var
{
bin
}
argument is
true, the binary pickle format is used; otherwise the (less efficient)
text pickle format is used (this is the default).
\end{funcdesc}
...
...
@@ -210,9 +256,19 @@ objects can actually be unpickled. See section~\ref{pickle-sec} for
more details on security concerns.
}
,
\class
{
Pickler
}
and
\class
{
Unpickler
}
:
\begin{classdesc}
{
Pickler
}{
file
\optional
{
,
bin
}}
\begin{classdesc}
{
Pickler
}{
file
\optional
{
,
protocol
\optional
{
, bin
}
}}
This takes a file-like object to which it will write a pickle data
stream. Optional
\var
{
bin
}
if true, tells the pickler to use the more
stream.
If the
\var
{
protocol
}
parameter is ommitted, protocol 0 is used.
If
\var
{
protocol
}
is specified as a negative value,
the highest protocol version will be used.
\versionchanged
[The
\var
{
bin
}
parameter is deprecated and only provided
for backwards compatibility. You should use the
\var
{
protocol
}
parameter instead]
{
2.3
}
Optional
\var
{
bin
}
if true, tells the pickler to use the more
efficient binary pickle format, otherwise the
\ASCII
{}
format is used
(this is the default).
...
...
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