[C++-sig] Multiple python interpreter contexts

Stefan Seefeld seefeld at sympatico.ca
Wed Feb 23 00:22:44 CET 2005


Stefan Seefeld wrote:
> Ralf W. Grosse-Kunstleve wrote:
> 
>> http://www.boost.org/libs/python/doc/tutorial/doc/html/python/object.html
>>
>> Look for "Beware" and "astute".
> 
> 
> "
> 
> Beware the common pitfall of forgetting that the constructors of most of 
> Python's mutable types make copies, just as in Python.
> 
> Python:
> 
>  >>> d = dict(x.__dict__)     # copies x.__dict__
>  >>> d['whatever']            # modifies the copy
> 
> "

Sorry, I realized the explicit use of the 'dict()' constructor making the
difference just after I hit the 'send' button.
Still, the original question remains, as the original poster did use something
like 'dict ns2 = dict(ns1)' and yet both objects had the same id, i.e. pointed
to the same object internally.
So it appears in that particular case dict(foobar) didn't really create a copy
of foobar.

Thanks,
		Stefan



More information about the Cplusplus-sig mailing list