[sage-devel] Just for fun

2021-08-06 Thread Kwankyu Lee
I bet this ticket has the simplest nontrivial patch: https://trac.sagemath.org/ticket/32314 -- 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

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread William Stein
On Fri, Aug 6, 2021 at 5:44 PM David Roe wrote: > > I think Nils' original solution, of adding an immutable keyword option to the > parent, is a good one. I've run into a similar issue with matrices, where I > had to make them immutable before using them as dictionary keys. > David > I agree

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread David Roe
I think Nils' original solution, of adding an immutable keyword option to the parent, is a good one. I've run into a similar issue with matrices, where I had to make them immutable before using them as dictionary keys. David On Fri, Aug 6, 2021 at 7:39 PM Nils Bruin wrote: > On Friday, 6

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Kwankyu Lee
Actually it depends: sage: def build(): : v = vector(ZZ, 1000) : for i in range(1000): : v[i] = Integer(i) : return v : : sage: def build2(): : l = list() : for i in range(1000): : l.append(Integer(i)) : return

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Nils Bruin
On Friday, 6 August 2021 at 16:31:23 UTC-7 wst...@gmail.com wrote: > To clarify, by "similar reasons to numpy", I meant that you open up > the possibility of using Cython, vectorized operations, JITs like > numba, etc. Some of these provide order of magnitude speedups and > aren't an option

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Nils Bruin
On Friday, 6 August 2021 at 14:13:19 UTC-7 wst...@gmail.com 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. > I wonder about that. The main reason why it's fast in numpy

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread William Stein
On Fri, Aug 6, 2021 at 4:16 PM Kwankyu Lee wrote: > > > > On Saturday, August 7, 2021 at 6:13:19 AM UTC+9 wst...@gmail.com 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

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Kwankyu Lee
On Saturday, August 7, 2021 at 6:13:19 AM UTC+9 wst...@gmail.com 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)

[sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Nils Bruin
On Friday, 6 August 2021 at 15:59:27 UTC-7 Kwankyu Lee wrote: > On Saturday, August 7, 2021 at 5:47:54 AM UTC+9 Nils Bruin wrote: > >> So how bad would it be to potentially double the number of vector spaces >> in existence by giving them an extra parameter determining whether fresh >> vectors

[sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Kwankyu Lee
On Saturday, August 7, 2021 at 5:47:54 AM UTC+9 Nils Bruin wrote: > So how bad would it be to potentially double the number of vector spaces > in existence by giving them an extra parameter determining whether fresh > vectors (such as those resulting from vector arithmetic) should be mutable

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread William Stein
On Fri, Aug 6, 2021 at 1:47 PM Nils Bruin wrote: > On Thursday, 5 August 2021 at 21:01:28 UTC-7 Kwankyu Lee wrote: > >> >> I looked into some. They use vectors like lists or mutable matrices. >> > > Yes, I expect that this will happen more with code in the future. People > who have exposure to

[sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-06 Thread Nils Bruin
On Thursday, 5 August 2021 at 21:01:28 UTC-7 Kwankyu Lee wrote: > > I looked into some. They use vectors like lists or mutable matrices. > Yes, I expect that this will happen more with code in the future. People who have exposure to numpy et.al. tend to write code that way. I suspect that in