Change in vdsm[master]: utils: faster albeit less general deepcopy

fromani at redhat.com fromani at redhat.com
Mon Nov 10 21:31:44 UTC 2014


Francesco Romani has posted comments on this change.

Change subject: utils: faster albeit less general deepcopy
......................................................................


Patch Set 2:

(4 comments)

thanks for the quick review!

http://gerrit.ovirt.org/#/c/34989/2/lib/vdsm/utils.py
File lib/vdsm/utils.py:

Line 30: from contextlib import contextmanager
Line 31: from fnmatch import fnmatch
Line 32: from StringIO import StringIO
Line 33: from weakref import proxy
Line 34: import cPickle
> I think already have this in compat, so you can do:
Right, I forgot, done.
Line 35: import errno
Line 36: import fcntl
Line 37: import functools
Line 38: import glob


Line 1172:     # Assume disabled if cannot find
Line 1173:     return -1
Line 1174: 
Line 1175: 
Line 1176: def fullcopy(obj):
> To make the limits more clear, lets call it picklecopy()
Nice suggestion. Renamed.
Line 1177:     """
Line 1178:     Returns a full (not shallow) copy of argument,
Line 1179:     like copy.deepcopy() does, but faster.
Line 1180: 


Line 1174: 
Line 1175: 
Line 1176: def fullcopy(obj):
Line 1177:     """
Line 1178:     Returns a full (not shallow) copy of argument,
> Lets call it deep copy, not full.
Done
Line 1179:     like copy.deepcopy() does, but faster.
Line 1180: 
Line 1181:     To be faster, this function expects the
Line 1182:     argument to be pickle-able.


Line 1185:     with primitive python types, including any
Line 1186:     arrangemente of them
Line 1187:     (e.g. dict() inside list() inside dict()).
Line 1188:     """
Line 1189:     return cPickle.loads(cPickle.dumps(obj, -1))
> Use cPickle.HIGHEST_PROTOCOL instead of -1.
Done


-- 
To view, visit http://gerrit.ovirt.org/34989
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I936a977e9f41863bdff18b9343d252ab0996d554
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list