404 questions
1 vote
1 answer
80 views
Shallow copying enumeration iterator behavior in Python
I am trying to understand the behavior of iterators in Python, particularly when using the copy.copy() and copy.deepcopy() functions. I have the following script: import copy my_list = ["a",...
2 votes
2 answers
288 views
Workaround `#24898`: MemberwiseClone is missing after upgrade to powershell 7.5.0
I bounced into this issue: #24898: MemberwiseClone is missing after upgrade to powershell 7.5.0: class MyClass { [string]$Name [object] CloneProblem() { return $this....
0 votes
2 answers
383 views
XSLT 3.0 - how do I correctly use apply-templates and copy-of?
I am fairly new to xslt 3.0 and have a problem that requires it's use. I am very close but my output is printing the text-only copy of the data that I do not want. I have to basically merge the T3 ...
0 votes
1 answer
63 views
Testing Value Objects in DDD, "Implementing Domain Driven Design"
In the book "Implementing Domain Driven Design" of Vaughn Vernon, in the Testing of Value Objects section, the author talks about how we can use just shallow copy instead of deep copy to ...
2 votes
3 answers
156 views
Does the nums array make a deep copy of letters[2:5] = ['C', 'D', 'E']?
I am learning shallow v.s. deep copying a list in Python. I learned that there're two ways to create copies that have the original values unchanged and only modify the new values or vice versa. They'...
2 votes
2 answers
67 views
I am confused in javascript shallow copy
'a' array wasn't affected. const a = [1,2,3] const b = [...a] // shallow copy b[0] = 9 console.log(a) // [1,2,3] console.log(b) // [9,2,3] results as expected ---------- const a = [{name:"John&...
0 votes
0 answers
62 views
Deep and shallow copy [duplicate]
I have trouble understanding the deep and shallow copy, and how the method .clone() works in Java. Some sources say it creates a shallow copy, others say it's deep. public class Kopie { public ...
0 votes
0 answers
88 views
Create a shallow copy of a single channel in OpenCV
In OpenCV, it's possible to create a cv::Mat representing a sub-rectangle of an existing cv::Mat, with cv::Mat::operator() functions. This is made possible by the Mat step parameter which enables non ...
0 votes
1 answer
80 views
Problems related to shallow copy in C++
I'm trying to understand the basics of C++ classes and the different forms of copying a class to another one, I made a simple class that use a table as a stack and i created simple function for ...
-1 votes
1 answer
190 views
Shallow copy equivalent for a vector in Rust
I am trying to implement an algorithm which requires the use of a second mutable vector (elements are read only) containing a subset of elements of the first vector. That subset is of different order ...
0 votes
0 answers
60 views
Using immutability-helper or spread op to make changes to an object, what is better: repeatedly $set, or $merge only once an object with all changes?
In my state I have a dictionary of a flat object: export interface INodeVisibility { id: string; level: number; isExpanded: boolean; } export type NodeVisibilityDict = { [key: string]: ...
0 votes
2 answers
84 views
Exploring React Shallow Copy Methods: Spread Operator vs Direct Assignment
I am currently working on a React project and encountered an interesting issue related to shallow copying objects. In my component, I have a form where I collect data, and I noticed that different ...
0 votes
0 answers
63 views
shallow copy problem with values and references
In python I have: x = [1,2,3,[4,5,6]] y = x[:] x[3][0] = 9 so now: x = [1,2,3,[9,5,6]] y = [1,2,3,[9,5,6]] but: x[0] = 99 then: x = [99,2,3,[9,5,6]] and: y = [1,2,3,[9,5,6]] how come when I ...
-1 votes
2 answers
123 views
In Java : How to duplicate "entirely" a Map with Collections as value? [duplicate]
The code below is illustrating my problem : public class TreeMapCopyProblem { private static TreeMap<Integer, SortedSet<Integer>> treeMap1; private static TreeMap<Integer, ...
0 votes
2 answers
74 views
Adding a new column to a df is not carrying over to a shallow copy of the df
I have a very simple df, which I'm going to make a shallow copy of. # assign dataframe old_df = pd.DataFrame({'values': [10, 20, 30, 40]}) # shallow copy copy_df = old_df.copy(deep=False) I ...