#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)
-
Google Coral USB Edge TPU Implementation Guide 1. Installation and Troubleshooting 1.1 Hardware Requirements Google Coral USB Accelerator ...
-
Logistic Classifier The logistic classifier is similar to equation of the plane. W is weight vector, X is input vector and y is output...
-
template < int INT> void AAA() { std::cout << "INT = " << INT << std::endl; } How to Call...
-
error: . VanillaPipeline.get_train_loss_dict: 12.6875 Traceback (most recent call last): File "/home/mare/anaconda3...
-
This article is the method about line fitting in 3d points. If we have these 3d points, how to find best 3d line? The main conc...
-
install Claude Code using this shell script . #!/bin/bash # install-claude.sh # Installs Node.js 18+, npm, and Claude Code CLI, handling co...
-
// ============================================================================ // SIMPLE COMPARISON: TUPLE vs VECTOR // When to use which...
-
refer to code: . from PIL import Image import json import yaml import os import argparse def get_image_dimensions ( image_path ): ...
-
// ============================================================================ // COMPLETE C++ TUPLE TUTORIAL // ==========================...
-
1. load pre-trained model 2. export onnx 3. load onnx refer to code: . import warnings from torch . jit import TracerWarning warnings . ...
No comments:
Post a Comment