From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9vHW-0006N0-9t for qemu-devel@nongnu.org; Tue, 20 Mar 2012 05:23:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9vHP-0005pV-Md for qemu-devel@nongnu.org; Tue, 20 Mar 2012 05:23:05 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:47105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9vHP-0005pD-CD for qemu-devel@nongnu.org; Tue, 20 Mar 2012 05:22:59 -0400 Received: by lbon3 with SMTP id n3so4167460lbo.4 for ; Tue, 20 Mar 2012 02:22:57 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20120313200332.24179.78152.stgit@ginnungagap.bsc.es> References: <20120313200235.24179.63987.stgit@ginnungagap.bsc.es> <20120313200332.24179.78152.stgit@ginnungagap.bsc.es> Date: Tue, 20 Mar 2012 09:22:56 +0000 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 10/12] trace: [tracetool] Automatically establish available backends and formats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-1?Q?Llu=EDs_Vilanova?= Cc: harsh@linux.vnet.ibm.com, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com 2012/3/13 Llu=EDs Vilanova : > Adds decorators to establish which backend and/or format each routine is = meant > to process. > > With this, tables enumerating format and backend routines can be eliminat= ed and > part of the usage message can be computed in a more generic way. > > Signed-off-by: Llu=EDs Vilanova > Signed-off-by: Harsh Prateek Bora > --- > =A0Makefile.objs =A0 =A0 =A0 =A0| =A0 =A06 - > =A0Makefile.target =A0 =A0 =A0| =A0 =A03 > =A0scripts/tracetool.py | =A0320 ++++++++++++++++++++++++++++++++--------= ---------- > =A03 files changed, 211 insertions(+), 118 deletions(-) I find the decorators are overkill and we miss the chance to use more straightforward approaches that Python supports. The decorators build structures behind the scenes instead of using classes in an open coded way. I think this makes it more difficult for people to modify the code - they will need to dig in to what exactly the decorators do - what they do is pretty similar to what you get from a class. I've tried out an alternative approach which works very nicely for formats. For backends it's not a perfect fit because it creates instances when we don't really need them, but I think it's still an overall cleaner approach: https://github.com/stefanha/qemu/commit/3500eb43f80f3c9200107aa0ca19a1b5730= 0ef8a What do you think? Stefan