#16137: lazy_list from various input data
-------------------------------------+-------------------------------------
       Reporter:  MatthieuDien       |        Owner:
           Type:  enhancement        |       Status:  new
       Priority:  major              |    Milestone:  sage-6.4
      Component:  misc               |   Resolution:
       Keywords:  LazyPowerSeries,   |    Merged in:
  lazy_list, days57                  |    Reviewers:
        Authors:  Vincent            |  Work issues:
  Delecroix, Matthieu Dien           |       Commit:
Report Upstream:  N/A                |  37e67683e7a2f10152ba3a01b8aed508fe92f0f1
         Branch:                     |     Stopgaps:
  u/MatthieuDien/lazy_list_from_various_input_data|
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by mantepse):

 Comments (IMPORTANT: I have hardly any understanding of python/cython
 necessities, so some of these may be very naive or stupid)

 1.) Concerning the *original* `lazy_list`, I would have expected that


 {{{
 sage: from sage.misc.lazy_list import lazy_list
 sage: l = lazy_list(Primes())
 sage: l[:100]
 }}}

 returns a list, not a lazy list.  (I'm aware of `l[:100].list()`, but this
 seems inconsistent: `l[0]` also returns an element, not a lazy list)

 Do you know a reason for this decision?  Possibly it's more practical,
 right?

 2.) Concerning the *new* `lazy_list` some things clearly don't work:

 {{{
 sage: from sage.misc.lazy_list import lazy_list_from_iterator
 sage: from itertools import count
 sage: l2 = lazy_list_from_iterator(count()); l2
 lazy list [0, 1, 2, ...]
 sage: l2[:10]
 (0, 10, 1)
 sage: l2[10]
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 <ipython-input-8-02ea92939ca1> in <module>()
 ----> 1 l2[Integer(10)]

 /home/rubey/sage-lazy_list/local/lib/python2.7/site-
 packages/sage/misc/lazy_list.so in
 sage.misc.lazy_list.lazy_list_from_iterator.__getitem__
 (build/cythonized/sage/misc/lazy_list.c:6074)()

 TypeError: 'int' object is not iterable
 }}}

 3.) Yes, I think that `lazy_list_from_fun` (besides: I would prefer
 `lazy_list_from_function`) should do precisely as you say.  Currently, it
 doesn't: I would have expected the following to return
 a lazy list full of empty lists...

 {{{
 sage: l3 = lazy_list_from_fun(lambda a, b: b); l3
 lazy list [[[...], [...], [...], [...]], [[...], [...], [...], [...]],
 [[...], [...], [...], [...]], ...]
 }}}

 4.) There are now two entry points: `lazy_list_from_fun` and
 `lazy_list_from_iterator`.  I would expect that in the end there is also a
 general purpose constructor which decides what to use
 depending on the type of the argument, right?

--
Ticket URL: <http://trac.sagemath.org/ticket/16137#comment:23>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to