On Wednesday, September 30, 2015 at 8:42:05 AM UTC-7, Nathann Cohen wrote:
>
> We might also want to remove this dependency of posets on 
> UniqueRepresentation. Despite creating this equality problem, 
> UniqueRepresentation also causes a memory problem by caching *all* 
> created posets in memory (makes some computations impossible). 
> Similarly, it is also responsible for slowness upon creation of 
> Posets, as every new poset is compared with the others. 
>

+1

There's a real cost to making things UniqueRepresentation (or 
UniqueFactory): The construction parameters need to be processed into a 
hashable structure, and then a hash must be computed. In case of a hash 
match (which should basically only happen when the object already exists), 
a further complete comparison needs to happen between the construction 
parameters.

If the construction parameters are sizable, then UniqueRepresentation has a 
real memory cost: these parameters will probably be in memory twice: once 
as content of the object and once as (processed) key in the 
UniqueRepresentation cache.

There are benefits: One can use "is" for some kinds of equality tests 
(which will be quick, but as described above at significant cost up front), 
and if the objects are used as bases for further constructions that 
participate in the coercion framework, it's basically required. Also, if 
you end up constructing the same object several times, in several places, 
you might have memory savings (but you probably need at least 3 references 
before savings might start to kick in)

In general, if you're constructing a parent by listing all the elements, 
then UniqueRepresentation/UniqueFactory is probably a big cost. I think 
this is the case with Poset?

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to