On Tue, May 27 2003 "Alexander R. Pruss" wrote:

> Bill,
> 
> > If you look at the source of the class Mapper, in the file
> > PyPlucker/Writer.py, you will see the code which does the actual
> > record-id assignment.
> 
> Yes.  I am looking at the fragment:
> 
>         for (url, doc) in collection.items():
>             self._get_id_for_doc(doc)
> 
> _get_id_for_doc assigns record numbers sequentially as it is called.  What I
> guess I don't understand is how collection.items() gets to have the order it
> does.  I don't think the items in it are in the order in which they were
> added to the collection.

Assuming collection is a Python dictionary, the order of the tuples the
items() method returns is basically random, although consistent.
Iteration through a Python dictionary (with keys(), values(), or
items()) happens in a consistent way (if you don't change the
dictionary, the next time the order will be the same), but that's about
all you can say (and even this shouldn't be relied on).

The "problem" is that dictionaries don't *have* an order.  You cannot
sort them.  The implementation uses a hash function, which, if it's any
good (and the Python hash function is pretty good), will randomize the
values pretty thoroughly.

-- Sjoerd Mullender <[EMAIL PROTECTED]>
_______________________________________________
plucker-dev mailing list
[EMAIL PROTECTED]
http://lists.rubberchicken.org/mailman/listinfo/plucker-dev

Reply via email to