From: Matt Rice <ratmice@gmail.com>
To: Siva Chandra <sivachandra@google.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFC - Python Scripting] New method gdb.Architecture.disassemble
Date: Thu, 07 Feb 2013 23:03:00 -0000 [thread overview]
Message-ID: <CACTLOFonLeT7KGHk+CPs2yA1Zc7mKQqb7Td0=nMeRFMQgFZfUg@mail.gmail.com> (raw)
In-Reply-To: <CAGyQ6gz3s7gB-cg+szXHY+hq8_-K21FqruLn-_TLsawKoAa0cA@mail.gmail.com>
On Wed, Feb 6, 2013 at 5:11 PM, Siva Chandra <sivachandra@google.com> wrote:
> On Wed, Feb 6, 2013 at 3:18 PM, Siva Chandra <sivachandra@google.com> wrote:
>> Based on what Matt says in his comments, it seems like a leaf row can
>> look like one of these 3 possibilities:
>>
>> 1. [1, 2, 3]
>> 2. ['a' : 1, 'b': 2, 'c': 3]
>> 3. ['a': 1, 'a': 2, 'a': 3]
>>
>> 1 and 2 can be encapsulated with fundamental Python data structures. I
>> am not aware of any fundamental Python data structure which can
>> capture 3. So, is using a helper class called LabelValuePair a good
>> idea? With this, all leaf rows can be lists whose elements are either
>> all values, or are all LabelValuePairs: [value, value, value] or
>> [LabelValuePair, LabelValuePair, LabelValuePair]. Does this sound
>> reasonable? We can always go in for a list of single element dicts,
>> but I think that kind of makes it ugly. LabelValuePair can look like
>> this (in its Python form):
>>
>> class LabelValuePair(object):
>> def __init__(self, label, value):
>> self.label = label # not a writable attribute
>> self.value = value # not a writable attribute
>
> Or, could it be a named tuple:
> http://docs.python.org/2.7/library/collections.html#collections.namedtuple
> The down side is that they are available only on Python 2.4 and higher.
I definitely agree that these make it possible to do the py-out stuff
without the headache of modifying existing ui-out callers which is
desirable,
and turning it into {'a': (1, 2, 3)} doesn't really achieve that due
to the single 'uiout_list_type' entry point currently available.
one nice thing about the latter is that any python version can parse
it via 'literal_eval'.
which means if someone wanted to replace mi with py-out as a wire protocol
they need to share either the named_tuple stuff, or the LabelValuePair
object code on both the gdb and py-out client side.
so, my preference had been to represent duplicate keys as dict with a
list value just because it makes parsing dead simple/can just use a
stock python, that said I definitely see the appeal of a custom class
or named tuple, so I'm sort of on the fence on this one.
next prev parent reply other threads:[~2013-02-07 23:03 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-04 14:09 Siva Chandra
2013-02-05 23:28 ` Doug Evans
2013-02-06 1:53 ` Siva Chandra
2013-02-06 20:00 ` Tom Tromey
2013-02-08 18:05 ` Doug Evans
2013-02-09 17:55 ` Matt Rice
2013-02-12 14:56 ` Siva Chandra
2013-02-12 21:18 ` Tom Tromey
2013-02-13 14:37 ` Siva Chandra
2013-02-13 17:52 ` Eli Zaretskii
2013-02-13 18:03 ` Tom Tromey
2013-02-13 19:50 ` Siva Chandra
2013-02-13 20:42 ` Doug Evans
2013-02-14 22:46 ` Siva Chandra
2013-02-15 6:43 ` Doug Evans
2013-02-15 17:32 ` Doug Evans
2013-02-15 17:40 ` Siva Chandra
2013-02-15 17:41 ` Siva Chandra
2013-02-15 18:57 ` Doug Evans
2013-02-15 20:36 ` Siva Chandra
2013-02-15 21:01 ` Siva Chandra
2013-02-16 5:30 ` Doug Evans
2013-02-16 8:47 ` Eli Zaretskii
2013-02-19 5:36 ` Siva Chandra
2013-02-19 15:51 ` Paul_Koning
2013-02-19 16:35 ` Eli Zaretskii
2013-02-19 16:38 ` Eli Zaretskii
2013-02-20 12:34 ` Siva Chandra
2013-02-20 18:44 ` Eli Zaretskii
2013-02-21 1:49 ` Siva Chandra
2013-02-06 19:58 ` Tom Tromey
2013-02-06 20:31 ` Phil Muldoon
2013-02-06 22:31 ` Matt Rice
2013-02-06 23:19 ` Siva Chandra
2013-02-07 1:11 ` Siva Chandra
2013-02-07 23:03 ` Matt Rice [this message]
[not found] ` <20130206235707.GA2353@klara.mpi.htwm.de>
2013-02-07 1:18 ` Siva Chandra
2013-02-07 14:14 ` Siva Chandra
2013-02-07 16:42 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACTLOFonLeT7KGHk+CPs2yA1Zc7mKQqb7Td0=nMeRFMQgFZfUg@mail.gmail.com' \
--to=ratmice@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=sivachandra@google.com \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox