�
��c@s]dZddkZddklZdefd��YZeZyddklZWne j
o
dZnXdddgZd �ZhZ
Zd
�ZxNed�eeeeeeeeeeieieif
D]Zeee<q�Wx;dD]3Zeeed�Zedj oeee<q���Zx!e e!e"fD]Zeee<qAWd�Z#edj oe#ee<nd�Z$e$eei%<[dgd�Z&hZ'Zd�Z(e(eed�<e(ee<e(ee<e(ee<e(ee<ye(ee)<Wne*j
onXe(ee<ye(ee+<Wne*j
onXye(eei,<Wne-j
onXe(ee<e(ee<e(eei<e(eei<e(eei<d�Z.e.ee <d�Z/e/ee<d�Z0e0ee!<edj oe0ee<nd�Z1d�Z2e2eei%<dd�Z3[[ddd��YZ4d�Z5e6djoe5�ndS(s�Generic (shallow and deep) copying operations.
Interface summary:
import copy
x = copy.copy(y) # make a shallow copy of y
x = copy.deepcopy(y) # make a deep copy of y
For module specific errors, 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
class instances).
- A shallow copy constructs a new compound object and then (to the
extent possible) inserts *the same objects* into it that the
original contains.
- A deep copy constructs a new compound object and then, recursively,
inserts *copies* into it of the objects found in the original.
Two problems often exist with deep copy operations that don't exist
with shallow copy operations:
a) recursive objects (compound objects that, directly or indirectly,
contain a reference to themselves) may cause a recursive loop
b) because deep copy copies *everything* it may copy too much, e.g.
administrative data structures that should be shared even between
copies
Python's deep copy operation avoids these problems by:
a) keeping a table of objects already copied during the current
copying pass
b) letting user-defined classes override the copying operation or the
set of components copied
This version does not copy types like module, class, function, method,
nor stack trace, stack frame, nor file, socket, window, nor array, nor
any similar types.
Classes can use the same interfaces to control copying that they use
to control pickling: they can define methods called __getinitargs__(),
__getstate__() and __setstate__(). See the documentation for module
"pickle" for information on these methods.
i�N(tdispatch_tabletErrorcBseZRS((t__name__t
__module__(((s/sys/lib/python/copy.pyR6s(tPyStringMaptcopytdeepcopycCs�t|�}ti|�}|o||�Snt|dd�}|o||�Snti|�}|o||�}n`t|dd�}|o|d�}n7t|dd�}|o
|�}ntd|��t||d�S(slShallow copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
t__copy__t
__reduce_ex__it
__reduce__s%un(shallow)copyable object of type %siN(ttypet_copy_dispatchtgettgetattrtNoneRRt_reconstruct(txtclstcopiertreductortrv((s/sys/lib/python/copy.pyRAs$
cCs|S(N((R((s/sys/lib/python/copy.pyt_copy_immutabledstComplexTypetUnicodeTypetCodeTypecCst|�|�S(N(R
(R((s/sys/lib/python/copy.pyt_copy_with_constructorpscCs
|i�S(N(R(R((s/sys/lib/python/copy.pyt_copy_with_copy_methoduscCs�t|d�o|i�Snt|d�o|i�}|i|�}nt�}|i|_t|d�o|i�}n
|i}t|d�o|i|�n|ii|�|S(NRt__getinitargs__t__getstate__t__setstate__( thasattrRRt __class__t_EmptyClassRt__dict__Rtupdate(Rtargstytstate((s/sys/lib/python/copy.pyt
_copy_instzs c
Cs�|djo
h}nt|�}|i||�}||j o|Snt|�}ti|�}|o|||�}n
yt|t�}Wntj
o
d}nX|ot||�}n�t|dd�}|o||�}n�t i|�}|o||�} n`t|dd�}|o|d�} n7t|dd�}|o
|�} nt
d|��t|| d|�}|||<t||�|S( siDeep copy operation on arbitrary Python objects.
See the module's __doc__ string for more info.
it__deepcopy__RiR s"un(deep)copyable object of type %siN(
RtidRR
t_deepcopy_dispatcht
issubclasst TypeErrort_deepcopy_atomicR
RRRt_keep_alive(
Rtmemot_niltdR$RRtisscRR((s/sys/lib/python/copy.pyR�sD
cCs|S(N((RR.((s/sys/lib/python/copy.pyR,�scCsAg}||t|�<x$|D]}|it||��qW|S(N(R(tappendR(RR.R$ta((s/sys/lib/python/copy.pyt_deepcopy_list�sc
Cs�g}x$|D]}|it||��q
Wt|�}y||SWntj
onXxFtt|��D],}||||j ot|�}PqnqnW|}|||<|S(N(R2RR(tKeyErrortrangetlenttuple(RR.R$R3R0ti((s/sys/lib/python/copy.pyt_deepcopy_tuple�s"
cCsSh}||t|�<x6|i�D](\}}t||�|t||�<q#W|S(N(R(t iteritemsR(RR.R$tkeytvalue((s/sys/lib/python/copy.pyt_deepcopy_dict�s
cCsHy|t|�i|�Wn&tj
o|g|t|�<nXdS(sMKeeps a reference to the object x in the memo.
Because we remember objects by their id, we have
to assure that possibly temporary objects are kept
alive by referencing them.
We store a reference at the id of the memo, which should
normally not be used unless someone tries to deepcopy
the memo itself...
N(R(R2R5(RR.((s/sys/lib/python/copy.pyR-s
cCs�t|d�o|i|�Snt|d�o.|i�}t||�}|i|�}nt�}|i|_||t|�<t|d�o|i�}n
|i}t||�}t|d�o|i |�n|ii
|�|S(NR'RRR(RR'RRRR R(RR!RR"(RR.R#R$R%((s/sys/lib/python/copy.pyt_deepcopy_insts" c
Cs�t|t�o|Snt|t�pt�|djo
h}nt|�}|djpt�|d \}}|djo|d}nh}|djo|d}nd}|djo|d} nd} |ot||�}n||�}
|
|t|�<|dj o<x9|D]-}|ot||�}n|
i|�q#Wn| dj oNxK| D]?\}}
|o"t||�}t|
|�}
n|
|
|<qlWn|o�|ot||�}nt |
d�o|
i
|�q�t|t�o#t|�djo|\}}nd}|dj o|
ii|�n|dj o1x.|i
�D]\}}
t|
||
�qiWq�n|
S(NiiiiR(iiii(t
isinstancetstrR8tAssertionErrorRR7RR(R2RRR!R"R;tsetattr(RtinfotdeepR.tntcallableR#R%tlistitertdictiterR$titemR<R=t slotstate((s/sys/lib/python/copy.pyR+sb
#
R cBseZRS((RR(((s/sys/lib/python/copy.pyR escCs�dddddd
ddghdd<dghg}t|�}||jGHtt|�}||jGHt|�}||jGHddd��Y}|d �}|i|�t|�}||jGH|GH|GHt|�}||jGH|GH|GH|ih||d<|d
d<�t|�}ddk}t|i|�GHt|i|�GHt|i|�GHt|i|�GHt|�}ddk}t|i|�GHt|i|�GHt|i|�GHt|i|�GHdS(Nilg�Q� @txyzzytabctABCtCcBs2eZdd�Zd�Zd�Zdd�ZRS(cSsbd|_||_tdjoddk}|id}nt}t|�|_|ii�dS(Nit__main__i�i( R3targRtsystargvt__file__topentfptclose(tselfRQRRtfile((s/sys/lib/python/copy.pyt__init__rs
cSsh|id<|id<S(NR3RQ(R3RQ(RX((s/sys/lib/python/copy.pyR|scSs1x*|i�D]\}}t|||�q
WdS(N(R;RC(RXR%R<R=((s/sys/lib/python/copy.pyR~s
cSs+|it|i|��}|i|_|S(N(RRRQR3(RXR.tnew((s/sys/lib/python/copy.pyR'�sN(RRRRZRRR'(((s/sys/lib/python/copy.pyROqs
sargument sketchitxyzi�(il(((RRtmapRR2trepr(tltl1ROtctl2tl3R^((s/sys/lib/python/copy.pyt_tesths@
'RP(sComplexTypesUnicodeTypesCodeType((7t__doc__ttypestcopy_regRt ExceptionRterrortorg.python.coreRtImportErrorRt__all__RRR0RR
tinttlongtfloattboolRAR8t frozensettxranget ClassTypetBuiltinFunctionTypetFunctionTypetttnameR
RtlisttdicttsetRR&tInstanceTypeRR)R,tcomplext NameErrortunicodeRtAttributeErrorR4R:R>R-R?RR RdR(((s/sys/lib/python/copy.pys<module>1s� !
3
5 5
|