From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24967 invoked by alias); 1 Sep 2011 22:57:05 -0000 Received: (qmail 24958 invoked by uid 22791); 1 Sep 2011 22:57:04 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-yw0-f41.google.com (HELO mail-yw0-f41.google.com) (209.85.213.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 01 Sep 2011 22:56:49 +0000 Received: by ywm13 with SMTP id 13so1926096ywm.0 for ; Thu, 01 Sep 2011 15:56:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.139.138 with SMTP id c10mr2369636yhj.62.1314917808237; Thu, 01 Sep 2011 15:56:48 -0700 (PDT) Received: by 10.236.34.162 with HTTP; Thu, 1 Sep 2011 15:56:48 -0700 (PDT) In-Reply-To: References: <1314198654-9008-1-git-send-email-ratmice@gmail.com> <1314198654-9008-5-git-send-email-ratmice@gmail.com> Date: Thu, 01 Sep 2011 23:13:00 -0000 Message-ID: Subject: Re: [PATCH 4/7] [python] API for macros: Add methods to get a gdb.Macro. From: Matt Rice To: pmuldoon@redhat.com Cc: Tom Tromey , gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-09/txt/msg00021.txt.bz2 On Tue, Aug 30, 2011 at 1:34 PM, Phil Muldoon wrote: > Phil Muldoon writes: > >> Tom Tromey writes: >> >>>>>>>> "Phil" =3D=3D Phil Muldoon writes: >>> >>> Phil> I think this should return a Tuple. =A0Tuples are immutable, and = unless >>> Phil> you for see a use for the user to manipulate the List, we should = guard >>> Phil> against it. =A0If you agree, please alter stpy_macros too. >>> >>> Using a tuple means you have to iterate twice -- once to count the >>> objects and once to make the tuple. >> >> You can use a list, and then convert it to a tuple: >> >> PyList_AsTuple >> >> We already use the above. >> >> If you wanted to, you could use PyTuple_Ruse, as long as there is >> one reference to the tuple. > > Apologies for the typos, but the above should read: > > =A0If you wanted too, you could use PyTuple_Resize, as long as there is > =A0only one reference to the tuple. I will try these out, (convert list->tuple and PyTuple_Resize()), but PyTuple_Resize is going to use realloc, which could end up moving it... As Tom mentioned, we create a new list every time, so really its not going to foul us up if the user does modify it. What would be preferred is an immutable list with a constant time append only exposed to the c api. but python doesn't really have one of these. I'll give it a shot and see how it performs, but my gut says list.