Colin == Colin J Williams c...@ncf.ca writes:
Colin s...@pobox.com wrote:
For extremely short lists, but not for much else:
% for n in 1 10 100 1000 1 10 ; do
echo len: $n
echo -n numpy:
python -m timeit -s 'import numpy ; a =
s...@pobox.com wrote:
Colin == Colin J Williams c...@ncf.ca writes:
Colin s...@pobox.com wrote:
For extremely short lists, but not for much else:
% for n in 1 10 100 1000 1 10 ; do
echo len: $n
echo -n numpy:
python -m timeit -s 'import
Colin That's interesting but that's not the
Colin way timeit is documented for Python 2.5:
Colin timeit( [number=100])
That's how it works when invoked as a main program using -m.
Colin In spite of the fact that your own data doesn't support the
Colin assertion?
s...@pobox.com wrote:
Colin ... perhaps faster than numpy:
...
For extremely short lists, but not for much else:
% for n in 1 10 100 1000 1 10 ; do
echo len: $n
echo -n numpy:
python -m timeit -s 'import numpy ; a = numpy.array(range('$n'))' 'a*3'
Hi!
map(multby3, (1, 2, 3, ))
...with lambda:
map(lambda x: x*3, [1,2,3])
@-salutations
--
Michel Claveau
--
http://mail.python.org/mailman/listinfo/python-list
Méta-MCI (MVP) wrote:
Hi!
map(multby3, (1, 2, 3, ))
with lambda: map(lambda x: x*3, [1,2,3])
@-salutations
More lines but perhaps faster than numpy:
PythonWin 2.5.4 (r254:67916, Dec 23
2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2008 Mark
Colin ... perhaps faster than numpy:
...
For extremely short lists, but not for much else:
% for n in 1 10 100 1000 1 10 ; do
echo len: $n
echo -n numpy:
python -m timeit -s 'import numpy ; a = numpy.array(range('$n'))' 'a*3'
echo -n list:
What does *not* work is
3 * [0,1,2]
As you know, this gives
[0,1,2,0,1,2,0,1,2]
What I am hoping for is
[0,3,6]
I see that I can use
numpy.multiply(3,range(3))
but this seems overkill to me. Can you tell I am coming to Python from
Matlab?
Thanks -- Rob--
On Fri, Dec 26, 2008 at 7:05 PM, robert.t.ly...@seagate.com wrote:
What does *not* work is
3 * [0,1,2]
As you know, this gives
[0,1,2,0,1,2,0,1,2]
What I am hoping for is
[0,3,6]
I see that I can use
numpy.multiply(3,range(3))
but this seems overkill to
What does *not* work is
3 * [0,1,2]
As you know, this gives
[0,1,2,0,1,2,0,1,2]
What I am hoping for is
[0,3,6]
I see that I can use
numpy.multiply(3,range(3))
but this seems overkill to me. Can you tell I am coming to Python from
Matlab?
The common way to do
Tim Chase wrote:
What does *not* work is 3 * [0,1,2]
As you know, this gives
[0,1,2,0,1,2,0,1,2]
What I am hoping for is
[0,3,6]
I see that I can use numpy.multiply(3,range(3))
The common way to do this is just
a1 = [0,1,2]
a2 = [x * 3 for x in a1]
...
But a
you might also want to look into the map(elem), and filter(elem) builtins
def multby3(elem):
... return elem * 3
...
map(multby3, (1, 2, 3, ))
[3, 6, 9]
help(map)
def even(elem):
... return not elem % 2
...
filter(even, (1, 2, 3, ))
(2,)
help(filter)
KeyboardInterrupt
map(multby3,
On Dec 26, 2008, at 19:05 , robert.t.ly...@seagate.com wrote:
but this seems overkill to me. Can you tell I am coming to Python
from Matlab?
if you're coming from matlab, then you should think of python lists
more like cell arrays than matrices: you can have lists of arbitrary
data
13 matches
Mail list logo