#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 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.
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 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.
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.
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.
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)
}}}
I have much more comments. I could also edit directly the file.
Vincent
--
Ticket URL: <http://trac.sagemath.org/ticket/16137#comment:57>
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.