Statement on Dismantling Systemic Racism

District 5 of the Knox County Democratic Party is committed to keeping our nation safe and fighting for equal opportunity for every American. We are outraged and sickened by the murder of George…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Shallow Copy vs Deep Copy vs Assignment in Python

A quick overview about shallow copy,deepcopy and assignment in python.

Copying objects can be done in three ways in Python:

Assignment Operation in python usually won’t create copies. It will create references to the existing object.

Example: int,string are immutable objects in python.

If the above example,if we assign x=y, both x and y will point to same object in memory.

Image Source: Author

If we try to modify the value of y=10, only value of y is changed. x remains the same.y will point to another int object 10

Same for str object also.

2. Mutable objects

Example: List,Set,Dictionary

Image Source: Author

Both x and y will point to same object in memory.

Add a comment

Related posts:

Try these Amazing ideas to celebrate your birthday during the lockdown

Feeling Sad? Your birthday is coming up but still, stuck in lockdown? Thinking of how you will go to celebrate your birthday. Can’t go to Restaurants, Clubs, Not able to meet friends? Guest what you…

The seat reservation API

In the journey to test several different pieces of technology, I built a stateless REST API to handle seat reservation of a multi-branch cinema. Core idea behind this is being able to handle multiple…

Confession Time

After about three months of marriage I was already starting to feel the need for something new. Specifically I wanted a new man, a new cock, and a new thrill. My husband was sweet and he knew that I…