Hello,

There is often a "check" argument which is set to True by default.

class MyClass:
  def __init__(self, data, check=True):
     # 1. initialize the data

     # 2. perform check
     if check:
        # potentially lengthy verification

2014-10-11 14:54 UTC+02:00, Jori Mantysalo <jori.mantys...@uta.fi>:
> This might be of general interest, even if this specific example is just
> for lattices.
>
> On Fri, 10 Oct 2014, Nathann Cohen wrote:
>
>>> About using hasse diagrams directly: Is it possible to do for example
>>> Posets.ChainPoset(500) without 10 seconds of cpu time?
>>
>> That such a thing takes so long does not make the slightest sense.
>> "%prun -s cumulative" says that a call to "copy" takes a lot of time,
>> and the call to 'meet' too. But whatever is called is clearly wasting
>> ressouces.
>
> ChainPoset() is oneliner:
> return LatticePoset((range(n), [[x,x+1] for x in range(n-1)]))
>
> This does
>
> P = Poset(data...)
> if not P.is_lattice():
>          raise ValueError("Not a lattice.")
>      return FiniteLatticePoset(P...)
>
> So first it checks that given data really is a poset (i.e. has no loops).
> After that it checks if poset is also lattice --- and it does so by really
> calculating meet- and join-matrices. For n=500 that means matrix with
> 500*500=250000 entries, because there is no support for lower or upper
> triangular matrices.
>
> Well, I guess we have shortcut: use FiniteLatticePoset directly. But
>
> n=500
> P=Poset((range(n), [[x,x+1] for x in range(n-1)]))
> L=FiniteLatticePosets(P)
>
> gives AssertionError.
>
>   * * *
>
> Is this a general pattern? It is good to check arguments also in
> "internal" use, so that we find programming errors easily. But sometimes
> there should be shortcuts to pass lenghty checks when we really know what
> we are doing. It this thinked on other parts of Sage?
>
> --
> Jori Mäntysalo
>
> --
> 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.
>

-- 
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