On Saturday, August 7, 2021 at 6:13:19 AM UTC+9 [email protected] wrote:
> Possible benefits may include:
>
> - potentially much faster: for similar reasons to numpy, a mutable sage
> vector can be much faster than a generic Python list.
>
>
sage: def build():
....: v = vector(QQ, 1000)
....: for i in range(1000):
....: v[i] = i/(i+1)
....: return v
....:
....:
sage: def build2():
....: l = list()
....: for i in range(1000):
....: l.append(i/(i+1))
....: return vector(QQ, l)
....:
....:
sage:
sage: timeit('build()')
125 loops, best of 3: 2.93 ms per loop
sage: timeit('build2()')
125 loops, best of 3: 2.74 ms per loop
sage: timeit('build()')
125 loops, best of 3: 2.9 ms per loop
sage: timeit('build2()')
125 loops, best of 3: 2.73 ms per loop
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sage-devel/15652d60-1f36-43cf-bb64-94622d1438acn%40googlegroups.com.