[Python-Dev] [RFC] PEP 418: Add monotonic time, performance counter and process time functions
Eric V. Smith
eric at trueblade.com
Sun Apr 29 01:20:51 CEST 2012
On 4/27/2012 11:40 PM, Guido van Rossum wrote:
> On Fri, Apr 27, 2012 at 5:50 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> 2) get_clock_info returns a dict. Why not a namedtuple?
>
> Future flexibility. And there's no need for it to be a *tuple*.
I haven't been paying attention to this discussion, so this isn't a
comment on any time functions specifically.
But we generally use a namedtuple (or structseq) for things like
get_clock_info. For example, for sys.float_info there's no need for it
to be a tuple, and it can be extended in the future, yet it's a structseq.
Same for sys.flags, although it's its own type, not a structseq. It is
also indexable, and we've added fields to it (hash_randomization was
added in 2.7.3).
So I think a structseq would work for get_clock_info as well. It's
unfortunate we don't have a similar type which isn't a tuple, but the
types we do have work well enough in practice.
Eric.
More information about the Python-Dev
mailing list