Mark Summerfield schrieb:
On 14 Sep, 21:23, James Stroud [EMAIL PROTECTED] wrote:
Mark Summerfield wrote:
I guess I'll have to rename my module (although unfortunately, my book
has just gone into production and I have a (simpler) example of what I
considered to be an ordered dict, so I will
On 14 Sep, 02:35, Jürgen Urner [EMAIL PROTECTED] wrote:
Puh, what a discussion... most common use case I can think of is
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
# do something that relies on order of keys as specified in the
constructor
It's a bit tireing having to type
for
I forgot one item in the proposed API:
ordereddict.delete(index : int)
Also, the API for keys() should be
ordereddict.keys(firstindex : int = None, secondindex : int = None)
If called with no args, returns list of all keys (in key order of
course); if one arg is given, returns keys with
On 2007-09-14, Mark Summerfield [EMAIL PROTECTED] wrote:
On 14 Sep, 02:35, Jürgen Urner [EMAIL PROTECTED] wrote:
Puh, what a discussion... most common use case I can think of is
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
# do something that relies on order of keys as specified in the
On 14 Sep, 10:49, Antoon Pardon [EMAIL PROTECTED] wrote:
On 2007-09-14, Mark Summerfield [EMAIL PROTECTED] wrote:
On 14 Sep, 02:35, Jürgen Urner [EMAIL PROTECTED] wrote:
Puh, what a discussion... most common use case I can think of is
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
On 2007-09-14, Mark Summerfield [EMAIL PROTECTED] wrote:
On 14 Sep, 10:49, Antoon Pardon [EMAIL PROTECTED] wrote:
# some time later
d[e] = 15
# later still
d[b] = 70
d.keys() # returns ['a', 'b', 'e', 'm', 'x']
d.values() # returns [1, 70, 15, 4, 20]
which seems to be exactly what
On 14 Sep, 12:46, Antoon Pardon [EMAIL PROTECTED] wrote:
On 2007-09-14, Mark Summerfield [EMAIL PROTECTED] wrote:
On 14 Sep, 10:49, Antoon Pardon [EMAIL PROTECTED] wrote:
# some time later
d[e] = 15
# later still
d[b] = 70
d.keys() # returns ['a', 'b', 'e', 'm', 'x']
On 2007-09-14, Mark Summerfield [EMAIL PROTECTED] wrote:
Also, it does not provide the key(), value(), and item() methods that
the API I proposed can support (because in an ordereddict, index
positions make sense).
At the time I wrote my module I never had a need for these. Do you have
a
On 14 Sep, 15:35, Antoon Pardon [EMAIL PROTECTED] wrote:
[snip]
I wish you all the luck you can get. Maybe if you succeed I'll change
my mind about writing a PEP myself.
However I think your chances will increase if you write your module
and have it available in the cheese shop. If people
Mark Summerfield wrote:
So to clarify, here's the entire API I'm proposing for ordereddict. In
all cases the ordereddict is always in (and kept in) key order, and
any method that returns a list or iterator always returns that list or
iterator (whether of keys or values) in key order:
On 14 Sep, 20:25, James Stroud [EMAIL PROTECTED] wrote:
Mark Summerfield wrote:
[snip]
May I also make one more suggestion, to call it a sort_ordered_dict
(or sortordereddict, or even better a sorteddict--where the ed
comes from ordered)? Its hard for me to move past the established
Mark Summerfield wrote:
I guess I'll have to rename my module (although unfortunately, my book
has just gone into production and I have a (simpler) example of what I
considered to be an ordered dict, so I will be adding to the
terminology confusion). That notwithstanding, given that it is a
On 14 Sep, 21:23, James Stroud [EMAIL PROTECTED] wrote:
Mark Summerfield wrote:
I guess I'll have to rename my module (although unfortunately, my book
has just gone into production and I have a (simpler) example of what I
considered to be an ordered dict, so I will be adding to the
On Thu, 13 Sep 2007 19:21:08 -0700, James Stroud wrote:
Carl Banks wrote:
On Sep 13, 4:20 pm, James Stroud [EMAIL PROTECTED] wrote:
Mark Summerfield wrote:
- If an item is inserted it is put in the right place (because the
underlying data structure, b*tree, skiplist or whatever is
On 13 Sep, 00:03, Paul Rubin http://[EMAIL PROTECTED] wrote:
Mark Summerfield [EMAIL PROTECTED] writes:
I feel that Python lacks one useful data structure: an ordered
dictionary.
Do other Python programmers feel this lack? Is this worth a PEP?
Yes. It should use a functional data
On 2007-09-12, Mark Summerfield [EMAIL PROTECTED] wrote:
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
wrote:
On Sep 12, 2:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
In fact, I'm not sure what
On Sep 13, 1:27 am, Mark Summerfield [EMAIL PROTECTED]
wrote:
On 13 Sep, 00:03, Paul Rubin http://[EMAIL PROTECTED] wrote:
Mark Summerfield [EMAIL PROTECTED] writes:
I feel that Python lacks one useful data structure: an ordered
dictionary.
Do other Python programmers feel this lack?
Mark Summerfield wrote:
- If an item is inserted it is put in the right place (because the
underlying data structure, b*tree, skiplist or whatever is
intrinsically ordered by on the key)
+1 for all your suggestions below, but -1 for the above. You suggest that
myOrderedDict['key'] = value
Mark Summerfield [EMAIL PROTECTED] writes:
Yes. It should use a functional data structure.
Could you elaborate?
I mean use a data structure like an AVL tree, that can make a new dict
object quickly, whose contents are the same as the old object except
for one element (i.e. most of the
James Stroud wrote:
set_value_at - set_value (not simply set)
Actually, 'set' seems better than set_value.
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 13, 4:20 pm, James Stroud [EMAIL PROTECTED] wrote:
Mark Summerfield wrote:
- If an item is inserted it is put in the right place (because the
underlying data structure, b*tree, skiplist or whatever is
intrinsically ordered by on the key)
+1 for all your suggestions below, but -1
Puh, what a discussion... most common use case I can think of is
d = {'a': 1, 'b': 2, 'c': 3}
for key in d:
# do something that relies on order of keys as specified in the
constructor
It's a bit tireing having to type
for key in sorted(d.keys()):
do_somethig_with(d[key])
Carl Banks wrote:
On Sep 13, 4:20 pm, James Stroud [EMAIL PROTECTED] wrote:
Mark Summerfield wrote:
- If an item is inserted it is put in the right place (because the
underlying data structure, b*tree, skiplist or whatever is
intrinsically ordered by on the key)
+1 for all your suggestions
On Sep 12, 9:33 am, Mark Summerfield [EMAIL PROTECTED]
wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
I find such data structures v. useful in C++. I know that in Python
the sort function is v. fast, but often I prefer never to sort but
simply to use an
Mark Summerfield wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
I find such data structures v. useful in C++. I know that in Python
the sort function is v. fast, but often I prefer never to sort but
simply to use an ordered data structure in the first
On Sep 12, 9:33 am, Mark Summerfield [EMAIL PROTECTED]
wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
I find such data structures v. useful in C++. I know that in Python
the sort function is v. fast, but often I prefer never to sort but
simply to use an
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
I find such data structures v. useful in C++.
[snip]
Personally, I've never missed an ordered dict. What do people use them
for?
In fact, I'm not sure
On Sep 12, 2:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
In fact, I'm not sure what people mean by ordered dicts. I assume they
mean the keys are ordered, not the values. But ordered by what? Insertion
order?
On Wed, 12 Sep 2007 09:51:02 +0200, stef wrote:
If you're going to extend the dictionary, there's one other flag I'm
continuously missing: case-insensitive key.
Completely untested and probably buggy as anything, but here's an
absolutely minimal case-insensitive dictionary.
class
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
wrote:
On Sep 12, 2:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
In fact, I'm not sure what people mean by ordered dicts. I assume they
mean the keys are
On Sep 12, 3:54 pm, Mark Summerfield [EMAIL PROTECTED]
wrote:
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
Actually I meant by key order, so insertion order doesn't matter at
all. If you need a dictionary-like data structure that respects
insertion order you could use a list of (key,
Steven D'Aprano [EMAIL PROTECTED] wrote:
In fact, I'm not sure what people mean by ordered dicts. I assume they
mean the keys are ordered, not the values. But ordered by what?
Insertion order? Modification order? Alphabetical order?
All of the above at different times. Usually I think they
Michele Simionato schreef:
On Sep 12, 2:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
In fact, I'm not sure what people mean by ordered dicts. I assume they
mean the keys are ordered, not the values. But ordered
From: Michele Simionato
On Sep 12, 3:54 pm, Mark Summerfield [EMAIL PROTECTED]
wrote:
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
Actually I meant by key order, so insertion order doesn't matter at
all. If you need a dictionary-like data structure that respects
insertion
On 9/12/07, Mark Summerfield [EMAIL PROTECTED] wrote:
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
wrote:
On Sep 12, 2:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
In fact, I'm not sure what
On Sep 12, 10:04 am, Michele Simionato [EMAIL PROTECTED]
wrote:
On Sep 12, 3:54 pm, Mark Summerfield [EMAIL PROTECTED]
wrote:
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
Actually I meant by key order, so insertion order doesn't matter at
all. If you need a dictionary-like
On Sep 12, 8:42 am, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
I find such data structures v. useful in C++.
[snip]
Personally, I've
On 2007-09-12, Mark Summerfield [EMAIL PROTECTED]
wrote:
Actually I meant by key order, so insertion order doesn't
matter at all. If you need a dictionary-like data structure
that respects insertion order you could use a list of (key,
value) tuples.
Another respondent asked about use cases.
On 12 Sep, 15:04, Michele Simionato [EMAIL PROTECTED]
wrote:
On Sep 12, 3:54 pm, Mark Summerfield [EMAIL PROTECTED]
wrote:
On 12 Sep, 13:46, Michele Simionato [EMAIL PROTECTED]
Actually I meant by key order, so insertion order doesn't matter at
all. If you need a dictionary-like data
In article [EMAIL PROTECTED],
Steven D'Aprano [EMAIL PROTECTED] wrote:
On Wed, 12 Sep 2007 07:33:45 +, Mark Summerfield wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
I find such data structures v. useful in C++.
[snip]
Personally, I've
Mark Summerfield wrote:
I feel that Python lacks one useful data structure: an ordered
dictionary.
Why it should be a dict. With it you can only maintain the order
x1x2x3... But by definition the order only requires x1=x2=x3...
There are many use cases where keys are not unique. I'd prefer a
Mark Summerfield [EMAIL PROTECTED] writes:
I feel that Python lacks one useful data structure: an ordered
dictionary.
Do other Python programmers feel this lack? Is this worth a PEP?
Yes. It should use a functional data structure.
--
http://mail.python.org/mailman/listinfo/python-list
42 matches
Mail list logo