From: Gianni Tedesco Subject: Re: [PATCH,v2]: add libxl python binding Date: Mon, 13 Sep 2010 14:34:22 +0100 Message-ID: <1284384862.17452.4265.camel@qabil.uk.xensource.com> References: <1284133746.17452.172.camel@qabil.uk.xensource.com> <1284137111.14311.6558.camel@zakaz.uk.xensource.com> <1284138221.17452.187.camel@qabil.uk.xensource.com> <1284216501.15518.193.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1284216501.15518.193.camel@localhost.localdomain> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ian Campbell Cc: Xen Devel , Ian Jackson List-Id: xen-devel@lists.xenproject.org On Sat, 2010-09-11 at 15:48 +0100, Ian Campbell wrote: > On Fri, 2010-09-10 at 18:03 +0100, Gianni Tedesco wrote: > > > > + ret = filter(lambda x:True, types) # deep copy > > I think this is more normally written "ret = list(types)", "ret = > types[:]", or: > from copy import copy > ret = copy(types) I think i prefer types[:] (forgot about that) - copy module is a nightmare and IMO nastiest part of python language is semantics viz deep vs shallow copies. Does list() even do deep copy?? (I had no idea) > Although given that the caller does: > types = tree_frob(types) > why is the deep copy necessary? tree_frob could work in-place. Well, it's going to end up doing the tree flattening for the keyed union type that needs to be handled. Just makes it simpler than keeping around an original list that may or may not contain what you think it does at that point.