integer copy
Alain Ketterlin
alain at universite-de-strasbourg.fr.invalid
Fri Oct 20 05:19:52 EDT 2017
"ast" <nomail at com.invalid> writes:
> "ast" <nomail at com.invalid> a écrit dans le message de
> news:59e9b419$0$3602$426a74cc at news.free.fr...
>
> Neither works for large integers which is
> even more disturbing
>
> a = 6555443
> b = copy.copy(a)
> a is b
>
> True
In copy.py:
| [...]
| def _copy_immutable(x):
| return x
| for t in (type(None), int, long, float, bool, str, tuple,
| frozenset, type, xrange, types.ClassType,
| types.BuiltinFunctionType, type(Ellipsis),
| types.FunctionType, weakref.ref):
| d[t] = _copy_immutable
| [...]
and d[t] is what decides how to copy, via _copy_dispatch.
So none of the types listed above will be actually copied.
It should be documented more precisely. You should file a
documentation-improvement request.
Also, the doc says:
| This version does not copy types like module, class, function, method,
| nor stack trace, stack frame, nor file, socket, window, nor array, nor
| any similar types.
But who knows what "similar types" are...
-- Alain.
More information about the Python-list
mailing list