Message100148
> So s.append(x) just copies the pointer, not the actual value.
Yes, that's a reasonable way to think about it (though the term 'reference' seems to more popular than 'pointer' in this context). It matches the implementation, too: internally, a list is represented as a resizable array of pointers to objects. (For CPython, anyway; alternative implementations of Python might differ.)
Implicit object copies are rare in Python.
comp.lang.python is a good place to ask questions about Python's object model. |
|
Date |
User |
Action |
Args |
2010-02-26 11:13:37 | mark.dickinson | set | recipients:
+ mark.dickinson, ughacks |
2010-02-26 11:13:37 | mark.dickinson | set | messageid: <1267182817.75.0.994788905241.issue8023@psf.upfronthosting.co.za> |
2010-02-26 11:13:36 | mark.dickinson | link | issue8023 messages |
2010-02-26 11:13:35 | mark.dickinson | create | |
|