Hi,
when you have lists with different lengths and want to zip them, you should
look at itertools.zip_longest
Greetings
Andre
--
https://mail.python.org/mailman/listinfo/python-list
On 13/04/17 07:30, Peter Otten wrote:
Verdict: not greedy ;)
Great (as I mentioned I did look at the code VERY quickly whilst VERY
tired and at first glance missed that it's doing almost exactly what my
code is doing except using the heapq to manage tracking the smallest
value rather than so
Erik wrote:
> Hi Peter,
>
> On 12/04/17 23:42, Peter Otten wrote:
>> Erik wrote:
>>
>>> I need to be able to lazily merge a variable number of already-sorted(*)
>>> variable-length sequences into a single sorted sequence.
>>
>> https://docs.python.org/dev/library/heapq.html#heapq.merge
>
> AFAIC
Erik writes:
> I need to be able to lazily merge a variable number of
> already-sorted(*) variable-length sequences
If the number of sequences is large, the traditional way is with the
heapq module.
--
https://mail.python.org/mailman/listinfo/python-list
On 12Apr2017 23:15, Erik wrote:
I need to be able to lazily merge a variable number of already-sorted(*)
variable-length sequences into a single sorted sequence. The merge should
continue until the longest sequence has been exhausted.
(*) They may in practice be a lazy source of data known to
On 4/12/2017 7:15 PM, Erik wrote:
Hi Peter,
On 12/04/17 23:42, Peter Otten wrote:
Erik wrote:
I need to be able to lazily merge a variable number of already-sorted(*)
variable-length sequences into a single sorted sequence.
https://docs.python.org/dev/library/heapq.html#heapq.merge
AFAICT
Hi Ian,
On 13/04/17 00:09, Erik wrote:
On 12/04/17 23:44, Ian Kelly wrote:
I would
just use "lowest = min(items, key=itemgetter(0))".
I had it in my head for some reason
that min() would return the smallest key, not the object (and hence I
wouldn't be able to know which sequence object to get
Hi Peter,
On 12/04/17 23:42, Peter Otten wrote:
Erik wrote:
I need to be able to lazily merge a variable number of already-sorted(*)
variable-length sequences into a single sorted sequence.
https://docs.python.org/dev/library/heapq.html#heapq.merge
AFAICT (looking at the Python 3.5 heapq i
On 12/04/17 23:44, Ian Kelly wrote:
This might be okay since Timsort on an already-sorted list should be
O(n). But there's not really any need to keep them sorted and I would
just use "lowest = min(items, key=itemgetter(0))".
Sure (and this was my main worry). I had it in my head for some reaso
On Wed, Apr 12, 2017 at 4:44 PM, Ian Kelly wrote:
> On Wed, Apr 12, 2017 at 4:15 PM, Erik wrote:
>> while len(items) > 1:
>> items.sort(key=lambda item: item[0])
>
> This might be okay since Timsort on an already-sorted list should be
> O(n). But there's not really any need to keep th
On Wed, Apr 12, 2017 at 4:15 PM, Erik wrote:
> Hi.
>
> I need to be able to lazily merge a variable number of already-sorted(*)
> variable-length sequences into a single sorted sequence. The merge should
> continue until the longest sequence has been exhausted.
>
> (*) They may in practice be a la
Erik wrote:
> I need to be able to lazily merge a variable number of already-sorted(*)
> variable-length sequences into a single sorted sequence.
https://docs.python.org/dev/library/heapq.html#heapq.merge
--
https://mail.python.org/mailman/listinfo/python-list
Hi.
I need to be able to lazily merge a variable number of already-sorted(*)
variable-length sequences into a single sorted sequence. The merge
should continue until the longest sequence has been exhausted.
(*) They may in practice be a lazy source of data known to only ever be
generated in
13 matches
Mail list logo