On Oct 15, 2007, at 6:07 PM, Steven D'Aprano wrote:
> On Mon, 15 Oct 2007 14:11:27 -0700, John Machin wrote:
>
>> On Oct 16, 12:47 am, Erik Jones <[EMAIL PROTECTED]> wrote:
>>
>>> Not between two consecutive reads, no. However, after any
>>> resizing of
>>> a dict the result of Python's hash f
On Mon, 15 Oct 2007 14:11:27 -0700, John Machin wrote:
> On Oct 16, 12:47 am, Erik Jones <[EMAIL PROTECTED]> wrote:
>
>> Not between two consecutive reads, no. However, after any resizing of
>> a dict the result of Python's hash function for any given newly
>> inserted key is extremely likely to
On Oct 16, 12:47 am, Erik Jones <[EMAIL PROTECTED]> wrote:
> Not between two consecutive reads, no. However, after any resizing
> of a dict the result of Python's hash function for any given newly
> inserted key is extremely likely to be different than it would have
> been before the resizing, i.
On Oct 14, 2007, at 5:27 PM, Steven D'Aprano wrote:
> On Sun, 14 Oct 2007 13:26:27 -0700, Erik Max Francis wrote:
>
>> Will McGugan wrote:
>>
>>> If I have two dictionaries containing identical values, can I be
>>> sure
>>> that the items() method will return tuples in the same order?
> [...]
>>
Steven D'Aprano <[EMAIL PROTECTED]> writes:
> I've never seen the point of a sorted dictionary, it's easy to just say:
> for key, value in sorted(D.items())
You might want just a subrange of the dictionary (say the 100th
through 150th items in sorted order) without having to sort the entire
dictio
On Oct 15, 8:27 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> I've never seen the point of a sorted dictionary, it's easy to just say:
>
> for key, value in sorted(D.items())
There are several applications that involve finding i such that key[i]
<= query < key[i+1] where the
On Sun, 14 Oct 2007 13:26:27 -0700, Erik Max Francis wrote:
> Will McGugan wrote:
>
>> If I have two dictionaries containing identical values, can I be sure
>> that the items() method will return tuples in the same order?
[...]
>> Can I rely on this behavior?
>
> Probably not.
Definitely not. S
Will McGugan wrote:
> If I have two dictionaries containing identical values, can I be sure
> that the items() method will return tuples in the same order?
>
> I tried an experiment with CPython and it does appear to be the case.
>
> >>> a=dict(a=1, b=1, c=2)
> >>> b=dict(c=2, a=1, b=1)
> >>
On Oct 14, 3:28 pm, Will McGugan <[EMAIL PROTECTED]> wrote:
> If I have two dictionaries containing identical values, can I be sure
> that the items() method will return tuples in the same order?
> ...
> Can I rely on this behavior?
No. To quote the python documentation:
> Keys and values are lis
Hi,
If I have two dictionaries containing identical values, can I be sure
that the items() method will return tuples in the same order?
I tried an experiment with CPython and it does appear to be the case.
>>> a=dict(a=1, b=1, c=2)
>>> b=dict(c=2, a=1, b=1)
>>> a
{'a': 1, 'c': 2, 'b': 1}
>>
10 matches
Mail list logo