Hi,

Despite the length, I prefer cardinality() since card() is vague and
obscure
(and len(), size(), and count() ambiguous).

I would argue that cardinality(),  as distinct from len(), should
consistently
return a Sage Integer (or some concept of cardinal number) rather than
a
Python int.

sage: X = Set([1,2,4])
sage: type(len(X))
<type 'int'>
sage: type(X.cardinality()) # change to Integer
<type 'int'>

Similarly one could distinguish len(x) and x.length() by their return
values
Python int's and Sage Integer's.

Natural numbers are missing, but it is not clear that one
implementation
will suit all intended uses:

   1) as a poset with i <= i+j (extended by other cardinalities);
   2) as a poset with i <= i*j;
   3) as an additive abelian monoid;
   4) as a multiplicative abelian monoid;
   5) etc.

Until one considers N in the context of its possible structures and
morphisms,
one  might as well restricting to the subset of integers.

 --David

On Feb 26, 11:02 am, Florent Hivert <[email protected]>
wrote:
>       Hi Vincent Delecroix,
>
> > There is a difference at the interpreter level, look at :
> > sage: timeit('len(l)')
> > 625 loops, best of 3: 229 ns per loop
> > sage: timeit('l.__len__()')
> > 625 loops, best of 3: 442 ns per loop
>
> > I don't know exactly why. Perhaps the len() do not have to parse the
> > list of methods of the object ?
>
> I'd guess : some python internal optimization for basic datatype. I.e. if l is
> a list the python interpreter looks directly into to data structure without
> calling .__len__() but it's special to lists.  
>
> > I really agree that the case of words is really special. A word has a
> > length but no cardinality. Perhaps it's the same for other
> > combinatorial object (but no combinatorial classes). And I think that
> > a word is more a combinatorial object.
>
> For combinatorial objects, in the "real life" (ie talk/course) as well as in
> MuPAD, we use to call this the size of the object. Eg: the size of a
> the permutations [3,1,2,5,4] is 5, the size of the partitions (3,2,1,1,1)
> is 8, the size of a tree is its number of node...
>
> > If we choose something for combinatorial classes the count is not so
> > bad, because a combinatorial class is not a list (there is no
> > repetition).
>
> It is not clear for me and in some case wrong... Some combinatorial class are
> multisets.
>
> Cheers,
>
> Florent
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to