> [b.pop(0)]
>
> This has to lookup the global b, resize it, create a new list,
> concatenate it with the list x (which creates a new list, not an in-place
> concatenation) and return that. The amount of work is non-trivial, and I
> don't think that 3us is unreasonable.
>
I forgot to take acc
On Wed, 20 Oct 2010 14:32:53 -0700, Daniel Wagner wrote:
> I really appreciate your solutions but they bring me to a new question:
> Why is my solution so inefficient? The same operation without the
> list/tuple conversion
>
> $ python /[long_path]/timeit.py 'a=[[1,2,3], [4,5,6]];b=[7,8];map(lamb
Many thanks for all these suggestions! here is a short proof that you
guys are absolutely right and my solution is pretty inefficient.
One of your ways:
$ python /[long_path]/timeit.py 'a=[(1,2,3),(4,5,6)];b=(7,8);[x+(y,)
for x,y in zip(a,b)]'
100 loops, best of 3: 1.44 usec per loop
And my
Daniel Wagner wrote:
> Hello Everyone,
>
> I'm new in this group and I hope it is ok to directly ask a question.
>
> My short question: I'm searching for a nice way to merge a list of
> tuples with another tuple or list. Short example:
> a = [(1,2,3), (4,5,6)]
> b = (7,8)
>
> After the merging
>On Wed, Oct 20, 2010 at 1:33 PM, Daniel Wagner
> wrote:
>> Any more efficient ways or suggestions are still welcome!
In article
James Mills wrote:
>Did you not see Paul Rubin's solution:
>
[x+(y,) for x,y in zip(a,b)]
> [(1, 2, 3, 7), (4, 5, 6, 8)]
>
>I think this is much nicer and probab
On Wed, Oct 20, 2010 at 1:33 PM, Daniel Wagner
wrote:
> Any more efficient ways or suggestions are still welcome!
Did you not see Paul Rubin's solution:
>>> [x+(y,) for x,y in zip(a,b)]
[(1, 2, 3, 7), (4, 5, 6, 8)]
I think this is much nicer and probably more efficient.
cheers
James
--
-- J
SOLVED! I just found it out
> I'm searching for a nice way to merge a list of
> tuples with another tuple or list. Short example:
> a = [(1,2,3), (4,5,6)]
> b = (7,8)
>
> After the merging I would like to have an output like:
> a = [(1,2,3,7), (4,5,6)]
The following code solves the problem:
>
I used the following code to add a single fixed value to both tuples.
But this is still not what I want...
>>>a = [(1,2,3), (4,5,6)]
>>>b = 1
>>>a = map(tuple, map(lambda x: x + [1], map(list, a)))
>>>a
[(1, 2, 3, 1), (4, 5, 6, 1)]
What I need is:
>>>a = [(1,2,3), (4,5,6)]
>>>b = (7,8)
>>> a = COD
On 20/10/2010 02:26, Paul Rubin wrote:
Daniel Wagner writes:
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8) ...
the output should look like:
a = [(1,2,3,7), (4,5,6,8)]
That is not really in
Daniel Wagner writes:
>> > My short question: I'm searching for a nice way to merge a list of
>> > tuples with another tuple or list. Short example:
>> > a = [(1,2,3), (4,5,6)]
>> > b = (7,8) ...
> the output should look like:
> a = [(1,2,3,7), (4,5,6,8)]
That is not really in the spirit of tuple
On Oct 19, 8:35 pm, James Mills wrote:
> On Wed, Oct 20, 2010 at 10:16 AM, Daniel Wagner
>
> wrote:
> > My short question: I'm searching for a nice way to merge a list of
> > tuples with another tuple or list. Short example:
> > a = [(1,2,3), (4,5,6)]
> > b = (7,8)
>
> > After the merging I would
On Wed, Oct 20, 2010 at 10:16 AM, Daniel Wagner
wrote:
> My short question: I'm searching for a nice way to merge a list of
> tuples with another tuple or list. Short example:
> a = [(1,2,3), (4,5,6)]
> b = (7,8)
>
> After the merging I would like to have an output like:
> a = [(1,2,3,7), (4,5,6)]
Hello Everyone,
I'm new in this group and I hope it is ok to directly ask a question.
My short question: I'm searching for a nice way to merge a list of
tuples with another tuple or list. Short example:
a = [(1,2,3), (4,5,6)]
b = (7,8)
After the merging I would like to have an output like:
a = [
13 matches
Mail list logo