On Thu, Jun 10, 2010 at 10:58 PM, Robert Bradshaw
<rober...@math.washington.edu> wrote:
>
> On Jun 10, 2010, at 8:17 PM, Jason Grout wrote:
>
>> On 6/10/10 12:25 PM, Florent Hivert wrote:
>>>
>>>      Hi There,
>>>
>>> I'd like to discuss a design question. Some time ago Adrien Boussicault
>>> and
>>> myself started to write some experimental code for copy-on-write in
>>> Sage/Python. The idea is now more or less dropped because performance
>>> gain was
>>> not so good and the syntax was not very usable.
>>
>> Rob and I were just talking yesterday how it's so inconvenient that
>> identity_matrix() now returns an immutable matrix, so constructing something
>> from it involves making a copy, which is not the most obvious thing to a new
>> person, or the most elegant thing to someone that has been using matrices
>> for a while now.  It would be fantastic if immutable matrices had
>> copy-on-write semantics, not necessarily for performance, but just for
>> usability after some of the recent design decisions (which I guess were made
>> for performance reasons).
>
> Copy on write *should* be rather easy to implement for matrices at least.

Just out of curiosity, is this what would happen below with what you
guys are envisioning
for immutable copy on write matrices?

sage: a = matrix(ZZ, 3)
sage: a[1,2] = 5
sage: a.set_immutable()
sage: a[1,2] = 7
sage: print a
7

If so, what about:

sage: A = M.hecke_matrix(2)
sage: A[1,2]
20
sage: A[1,2] = 5; A
5
sage: M.hecke_matrix(2)[1,2]
20

I think the above would be very, very confusing to me.   If immutable
matrices *act* as if they are fully mutable, but basically silently
have completely different semantics, this will be confusing.

 -- William



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to