#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 | 6f7cfd949cc0956c0490813a7024cb7a8182324e
Branch: | Stopgaps:
public/lazy_list_from_various_input_data|
Dependencies: |
-------------------------------------+-------------------------------------
Comment (by MatthieuDien):
Hi there,
Thanks you very much for the answers.
I will try to justify some of my choices and answer to some of your new
questions.
Replying to [comment:57 vdelecroix]:
> Hi Matthieu,
>
> It would be nice to write documentation in the classes, particularly
> - what is the input
> - how does it work internally
> It would help me to read your code.
Yes, I have to do this
> Do you really want to keep the ``start, stop, step`` for all classes? I
would rather add a class `lazy_list_slice` which does the job.
I agree.
> I do not understand anything to `lazy_list_explicit`. Why do you use a
cache mechanism for it? Moreover, the following
> {{{
> cdef int update_cache_up_to(self, Py_ssize_t i) except -1:
> while PyList_GET_SIZE(self.cache) <= i:
> PyList_Append(self.cache, None)
> }}}
> is definitely useless since you can use the
`self.cache.extend([None]*length)` which would be much faster.
Thanks for the hint, I did not know {{{extend}}}.
Concerning the usage of a cache mechanism for {{{lazy_list_explicit}}}, it
is because the computation of a list's cell can be long (for example when
you compute the Cauchy's product during a lazy series' multiplication).
Then, the cache mechanism allows to compute only one time the value
contained in a cell.
> Are you sure you understand the point of `Py_INCREF(object)`? If you
call it when you should not, it implies that the object will *never* be
garbage collected. The call to this function is generally not needed in
Cython file.
For this point, I have to check that the value is garbage collected, but
without this instruction, the value is garbage collected instantly.
> Now Cython supports iterator, i.e. you can write
> {{{
> cdef class MyClass(X):
> def __iter__(self):
> cdef Py_ssize_t i
> for i in range(self.x,self.y,self.z):
> yield self.cache[i]
> }}}
> So I would remove all iterators "XYZ_iterator" and implement directly
the methods `__iter__` when possible.
Ok, I did not know this. I will benchmark the both approaches.
> If you add the line
> {{{
> include "sage/ext/stdsage.pxi"
> }}}
> at the begining of the file you have access to better then "isinstance"
to test the type of an object
> {{{
> PY_TYPE_CHECK(object)
> PY_TYPE_CHECK_EXACT(object)
> }}}
Thanks for the hint.
> I have much more comments. I could also edit directly the file.
> Vincent
Replying to [comment:56 mantepse]:
>Hi Matthieu!
>I watched you work :-) THANK YOU!!!
>Right now I have only two comments:
>1.) I think the naming scheme for the classes should be changed:
>a) from_iterator is fine
>b) from_function is misleading. In fact, in analogy to a) I would expect
this class to do precisely >what explicit does. Isn't it precisely
recursive?
{{{from_function}}} is recursive yes. Do you have an idea about the name
(I am really bad to choose name ..) ?
>c) explicit should in my opinion be named from_function
>d) periodic is fine
>I also would suggest to change stopped to terminating or finite.
{{{finite}}} looks better to me, if Vincent agrees ?
>2.) I still don't understand the relationship with Family. I guess it's
fine not to consider >Sequence right now, but I think the relationship
with Family should be clarified. As a concrete >question: should Family
use lazy_list for sequences?
I think that this question deserves a new ticket because it can involve
modification of the code in an other part of Sage. We can work on it if
you want.
Matthieu
--
Ticket URL: <http://trac.sagemath.org/ticket/16137#comment:58>
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.