#this is Shallow copy a=[1, 2, 3] b=a a[0] = 38 print(a, b) print(id(a), id(b)) #[38, 2, 3] [38, 2, 3] #4320547040 4320547040 #this is deep copy b = a[:] print(id(a), id(b)) #4320427976 4320427472 a[0] = 50; print(a, b) #[50, 2, 3] [38, 2, 3] import copy a=[1,2,3] b = copy.deepcopy(a) a[0] = 38 print(a, b) [38, 2, 3] [1, 2, 3]
1/22/2014
(Python study) deep copy and shallow copy (example source code)
Subscribe to:
Post Comments (Atom)
-
I use MOG2 algorithm to background subtraction. The process is resize to small for more fast processing to blur for avoid noise affectio...
-
Created Date : 2011.2 Language : C/C++ Tool : Microsoft Visual C++ 2010 Library & Utilized : OpenCV 2.2 Reference : Interent Refer...
-
This example source code is to extract HOG feature from images. And save descriptors to XML file. The source code explain how to use HOGD...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
This is data acquisition source code of LMS511(SICK co.) Source code is made by MFC(vs 2008). The sensor is communicated by TCP/IP. ...
-
* Introduction - The solution shows panorama image from multi images. The panorama images is processing by real-time stitching algorithm...
-
fig 1. Left: set 4 points (Left Top, Right Top, Right Bottom, Left Bottom), right:warped image to (0,0) (300,0), (300,300), (0,300) Fi...
-
Created Date : 2007.1 Language : C/C++ Tool : Microsoft Visual C++ 6.0 Library & Utilized : OpenCV 1.0 Reference : Learning Ope...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
Video stabilization example source code. The principle is like that... Firstly, to obtain 2 adjacent images extract good feature to t...
No comments:
Post a Comment