Changing value of a point coordinate problem

I create a point and then copy its coordinates.
I then change the x value of the coordinate I just copied.
When I display both the coordinate of the original point and the new point
both of then now have the new value. I don’t understand why the original coordinate’s value
has changed. It was not modified. I’ve never seen this in a programming language.

What am I not seeing.

import rhinoscriptsyntax as rs

Gpt = rs.GetPoint(“xxx”)
ptpt = rs.AddPoint(Gpt)
print "Gpt ", Gpt
print "ptpt ", ptpt

npt = Gpt

print "Gpt ", Gpt
print "npt ", npt

npt[0] = npt[0] + 0.1

print "Gpt ", Gpt
print "pt ", npt

newpt = rs.AddPoint(npt)
print "new ", newpt

npt = Gpt
you are creating a pointer to an existing point, not creating a new point.
therefore any changes to npt will actually be you modifying Gpt.

One common example is if you copy one list into another.
any changes to items in the second list will affect the original list.

I thought I was creating another coordinate with same values similar to standard programming which is
how I learned to copy data.
I miss read the debugger too. It showed two distinct label.


Copying values only works with basic data types such as float, int, bool.
Classes such as point when applying equals are shallow copies.
Extra reading: