On Fri, 2009-04-10 at 19:44 -0400, Alex Gaynor wrote:
> 
> 
> On Fri, Apr 10, 2009 at 7:40 PM, Malcolm Tredinnick
> <malc...@pointy-stick.com> wrote:
[...]
>         
>         Particularly with iterators, storing the (next head item, rest
>         of
>         iterator) pair in a heap leads to a very neat and fast way to
>         create a
>         combined iterator. Here's one professional-quality
>         implementation that I
>         would recommend: http://code.activestate.com/recipes/491285/
> 
> It has one unfortunate failing(which is the fault of the heapq
> library), it doesn't take a key/cmp function like sorted does.  It is
> otherwise completely excellent though.

It's Python and so is the heap module! Modifying things is easy. I've
used the same solution with custom comparison functions one a number of
occasions. Even writing a small heap implementaiton with a custom
comparison is only about two dozen lines. Come on, think a little bit
outside the box!

Regards,
Malcolm




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to