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
3d29955a
Kaydet (Commit)
3d29955a
authored
Kas 30, 1998
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Markup improvements to help with conversions.
üst
01d5d940
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
27 deletions
+33
-27
libcopy.tex
Doc/lib/libcopy.tex
+33
-27
No files found.
Doc/lib/libcopy.tex
Dosyayı görüntüle @
3d29955a
...
...
@@ -4,9 +4,9 @@
\modulesynopsis
{
Shallow and deep copy operations.
}
\
setindexsubitem
{
(copy function)
}
\ttindex
{
copy
}
\ttindex
{
deepcopy
}
\
withsubitem
{
(in module copy)
}{
%
\ttindex
{
copy
}
%
\ttindex
{
deepcopy
}
}
This module provides generic (shallow and deep) copying operations.
...
...
@@ -19,7 +19,7 @@ x = copy.copy(y) # make a shallow copy of y
x = copy.deepcopy(y) # make a deep copy of y
\end{verbatim}
%
For module specific errors,
\
code
{
copy.error
}
is raised.
For module specific errors,
\
exception
{
copy.error
}
is raised.
The difference between shallow and deep copying is only relevant for
compound objects (objects that contain other objects, like lists or
...
...
@@ -49,13 +49,13 @@ Recursive objects (compound objects that, directly or indirectly,
contain a reference to themselves) may cause a recursive loop.
\item
Because deep copy copies
\emph
{
everything
}
it may copy too much,
e.g.
\
administrative data structures that should be shared even betwe
en
copies.
Because deep copy copies
\emph
{
everything
}
it may copy too much,
e.g., administrative data structures that should be shared ev
en
between
copies.
\end{itemize}
Python's
\code
{
deepcopy()
}
opera
tion avoids these problems by:
The
\function
{
deepcopy()
}
func
tion avoids these problems by:
\begin{itemize}
...
...
@@ -75,24 +75,30 @@ any similar types.
Classes can use the same interfaces to control copying that they use
to control pickling: they can define methods called
\code
{__
getinitargs
__
()
}
,
\code
{__
getstate
__
()
}
and
\code
{__
setstate
__
()
}
. See the description of module
\code
{
pickle
}
for information on these methods.
The copy module does not use the
\module
{
copy
_
reg
}
registration
module.
\refstmodindex
{
pickle
}
\setindexsubitem
{
(copy protocol)
}
\ttindex
{__
getinitargs
__}
\ttindex
{__
getstate
__}
\ttindex
{__
setstate
__}
\method
{__
getinitargs
__
()
}
,
\method
{__
getstate
__
()
}
and
\method
{__
setstate
__
()
}
. See the description of module
\module
{
pickle
}
\refstmodindex
{
pickle
}
for information on these
methods. The
\module
{
copy
}
module does not use the
\module
{
copy
_
reg
}
registration module.
\withsubitem
{
(copy protocol)
}{
%
\ttindex
{__
getinitargs
__
()
}
%
\ttindex
{__
getstate
__
()
}
%
\ttindex
{__
setstate
__
()
}}
In order for a class to define its own copy implementation, it can
define special methods
\method
{__
copy
__
()
}
\ttindex
{__
copy
__}
and
\method
{__
deepcopy
__
()
}
\ttindex
{__
deepcopy
__}
. The former is called to
implement the shallow copy operation; no additional arguments are
passed. The latter is called to implement the deep copy operation; it
is passed one argument, the memo dictionary. If the
\method
{__
deepcopy
__
()
}
implementation needs to make a deep copy of a
component, it should call the
\function
{
deepcopy()
}
function with the
component as first argument and the memo dictionary as second
argument.
define special methods
\method
{__
copy
__
()
}
and
\method
{__
deepcopy
__
()
}
. The former is called to implement the
shallow copy operation; no additional arguments are passed. The
latter is called to implement the deep copy operation; it is passed
one argument, the memo dictionary. If the
\method
{__
deepcopy
__
()
}
implementation needs to make a deep copy of a component, it should
call the
\function
{
deepcopy()
}
function with the component as first
argument and the memo dictionary as second argument.
\withsubitem
{
(copy protocol)
}{
%
\ttindex
{__
copy
__
()
}
%
\ttindex
{__
deepcopy
__
()
}}
\begin{seealso}
\seemodule
{
pickle
}{
Discussion of the special disciplines used to
support object state retrieval and restoration.
}
\end{seealso}
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