ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 28 Sep 2012 06:00:10 +0200Creating Element Classeshttps://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 = vFri, 28 Sep 2012 01:36:08 +0200https://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>
https://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/11490Fri, 28 Sep 2012 05:42:47 +0200https://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>
https://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!Fri, 28 Sep 2012 06:00:10 +0200https://ask.sagemath.org/question/9359/creating-element-classes/?comment=18989#post-id-18989