#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)
-
ð FREE License Plate Recognition API - No Credit Card Required! Want to try ANPR (Automatic Number Plate Recognition) / ALPR (Automatic L...
-
refer to code: . import ezdxf import random import matplotlib . pyplot as plt # Random DXF file generator def random_point (): r...
-
Open Source License Commercial Use Guide Understanding Commercial Rights in Open Source Licenses ð Legend ✅ Free : Comm...
-
ð§ AWS SAM Troubleshooting - Fixing pip/runtime and AWS CLI Issues If you're deploying AWS Lambda functions with SAM (Serverless Appli...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
Background subtractor example souce code. OpenCV support about 3 types subtraction algorithm. Those are MOG, MOG2, GMG algorithms. Det...
-
The MNIST dataset is a dataset of handwritten digits, comprising 60 000 training examples and 10 000 test examples. The dataset can be downl...
-
V1 =[ 10 20 30 40 50 60 70]; V2 = V1( :, randperm( length(V1) )); V2 = 60 10 20 30 50 40 70
-
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...
-
Image size of origin is 320*240. Processing time is 30.96 second took. The result of stitching The resul...
No comments:
Post a Comment