ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 27 Sep 2012 23:00:10 -0500Creating Element Classeshttp://ask.sagemath.org/question/9359/creating-element-classes/Hi! I want to be able to create elements, and want their parents to be elements, so I've been reading this page: http://www.sagemath.org/doc/reference/sage/structure/element.html.
The example shows Cython commands it seems (cdef v def).... Why? Couldn't I just do this in Python?
Excerpt from page cited above.
Elements typically define a method _new_c, e.g.,
cdef _new_c(self, defining data):
cdef FreeModuleElement_generic_dense x
x = PY_NEW(FreeModuleElement_generic_dense)
x._parent = self._parent
x._entries = vThu, 27 Sep 2012 18:36:08 -0500http://ask.sagemath.org/question/9359/creating-element-classes/Answer by Volker Braun for <p>Hi! I want to be able to create elements, and want their parents to be elements, so I've been reading this page: <a href="http://www.sagemath.org/doc/reference/sage/structure/element.html">http://www.sagemath.org/doc/reference...</a>.</p>
<p>The example shows Cython commands it seems (cdef v def).... Why? Couldn't I just do this in Python? </p>
<p>Excerpt from page cited above.</p>
<p>Elements typically define a method _new_c, e.g.,</p>
<p>cdef _new_c(self, defining data):
cdef FreeModuleElement_generic_dense x
x = PY_NEW(FreeModuleElement_generic_dense)
x._parent = self._parent
x._entries = v</p>
http://ask.sagemath.org/question/9359/creating-element-classes/?answer=14071#post-id-14071Elements can be implemented in plain Python and in Cython. Often, Cython is used for speed but you don't have to.
You should have a look at the worksheet on http://trac.sagemath.org/11490Thu, 27 Sep 2012 22:42:47 -0500http://ask.sagemath.org/question/9359/creating-element-classes/?answer=14071#post-id-14071Comment by SLOtoSF for <p>Elements can be implemented in plain Python and in Cython. Often, Cython is used for speed but you don't have to.</p>
<p>You should have a look at the worksheet on <a href="http://trac.sagemath.org/11490">http://trac.sagemath.org/11490</a></p>
http://ask.sagemath.org/question/9359/creating-element-classes/?comment=18989#post-id-18989Wonderful. I had no idea that there were these educational worksheets about Sage development. Is there a general repository for them? (I've posted this as a different question). Thanks!Thu, 27 Sep 2012 23:00:10 -0500http://ask.sagemath.org/question/9359/creating-element-classes/?comment=18989#post-id-18989