On Sun, Dec 1, 2019 at 7:49 AM C. Titus Brown wrote:
1. Put it on python.org, perhaps replacing the content here:
> https://www.python.org/dev/.
I think that's a fine idea -- that page is really pretty limited, it could
use a fleshing out. However, I'm not sure it's best to replace that page
> On Dec 1, 2019, at 8:15 AM, Jonathan Goble wrote:
>
> On Sun, Dec 1, 2019, 11:06 AM Ned Batchelder wrote:
> On 12/1/19 10:45 AM, C. Titus Brown wrote:
> > Hi folks,
> >
> > sorry, took me more than a few months, but I wrote a draft of a
> > python-ideas HOWTO here,
> >
> >
On Sun, Dec 1, 2019, 11:06 AM Ned Batchelder wrote:
> On 12/1/19 10:45 AM, C. Titus Brown wrote:
> > Hi folks,
> >
> > sorry, took me more than a few months, but I wrote a draft of a
> python-ideas HOWTO here,
> >
> > https://hackmd.io/@-6xkuCDkTrSFptQEimAdcg/B1noEGh2H
>
> Thanks so much for
On 12/1/19 10:45 AM, C. Titus Brown wrote:
Hi folks,
sorry, took me more than a few months, but I wrote a draft of a python-ideas
HOWTO here,
https://hackmd.io/@-6xkuCDkTrSFptQEimAdcg/B1noEGh2H
Thanks so much for writing this. I think Python-Ideas is a perfect
example of something that
Hi folks,
sorry, took me more than a few months, but I wrote a draft of a python-ideas
HOWTO here,
https://hackmd.io/@-6xkuCDkTrSFptQEimAdcg/B1noEGh2H
Thanks to Eric Smith and Chris Barker for their link suggestions, and Chris
Angelico and Guido van Rossum for their additional thoughts in a
Optimizations to namedtuple would likely be welcomed. __slots__ is the
optimization for objects that don't need dicts. Ordered by performance:
tuple, namedtuple, object, dataclass. A more raw struct would be faster:
https://docs.python.org/3/c-api/tuple.html#struct-sequence-objects
On 2019-12-01 10:11 a.m., Kyle Stanley wrote:
>>> for item in data.items(): item[0], item[1]
874 µs ± 21.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> for key, value in data.items(): key, value
524 µs ± 4.26 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> for
>>> for item in data.items(): item[0], item[1]
874 µs ± 21.5 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> for key, value in data.items(): key, value
524 µs ± 4.26 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
>>> for item in items_tuple(data): item.key, item.value
My mistake, I skimmed and assumed that the question was asking for this:
from collections import namedtuple
data = {'1': 1, 'two-2': 2}
x = namedtuple('x', data.keys())
# ValueError: Type names and field names must be valid identifiers: '1'
# But now understand that the request was for this:
30.11.19 23:16, Soni L. пише:
It'd be quite nice if dict.items() returned a namedtuple so all these
x[0], x[1], el[0], el[1], etc would instead be x.key, x.value, el.key,
el.value, etc. It would be more readable and more maintainable.
It was discussed before. The problem is that creating,
10 matches
Mail list logo