Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
0a2e5351
Commit
0a2e5351
authored
Dec 04, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provide Python complex type as cpython.complex.complex
parent
d9ce56c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
Cython/Includes/cpython/complex.pxd
Cython/Includes/cpython/complex.pxd
+10
-1
tests/run/builtincomplex.pyx
tests/run/builtincomplex.pyx
+29
-0
No files found.
Cython/Includes/cpython/complex.pxd
View file @
0a2e5351
cdef
extern
from
"Python.h"
:
cdef
extern
from
"Python.h"
:
ctypedef
struct
Py_complex
ctypedef
struct
Py_complex
:
double
imag
double
real
############################################################################
############################################################################
# 7.2.5.2 Complex Numbers as Python Objects
# 7.2.5.2 Complex Numbers as Python Objects
...
@@ -9,6 +12,12 @@ cdef extern from "Python.h":
...
@@ -9,6 +12,12 @@ cdef extern from "Python.h":
# PyComplexObject
# PyComplexObject
# This subtype of PyObject represents a Python complex number object.
# This subtype of PyObject represents a Python complex number object.
ctypedef
class
__builtin__
.
complex
[
object
PyComplexObject
]:
cdef
Py_complex
cval
# not making these available to keep them read-only:
#cdef double imag "cval.imag"
#cdef double real "cval.real"
# PyTypeObject PyComplex_Type
# PyTypeObject PyComplex_Type
# This instance of PyTypeObject represents the Python complex
# This instance of PyTypeObject represents the Python complex
# number type. It is the same object as complex and
# number type. It is the same object as complex and
...
...
tests/run/builtincomplex.pyx
0 → 100644
View file @
0a2e5351
from
cpython.complex
cimport
complex
def
complex_attributes
():
"""
>>> complex_attributes()
(1.0, 2.0)
"""
cdef
complex
c
=
1
+
2j
return
(
c
.
real
,
c
.
imag
)
def
complex_attributes_assign
():
"""
>>> complex_attributes_assign()
(10.0, 20.0)
"""
cdef
complex
c
=
1
+
2j
c
.
cval
.
real
,
c
.
cval
.
imag
=
10
,
20
return
(
c
.
real
,
c
.
imag
)
def
complex_cstruct_assign
():
"""
>>> complex_cstruct_assign()
(10.0, 20.0)
"""
cdef
complex
c
=
1
+
2j
cval
=
&
c
.
cval
cval
.
real
,
cval
.
imag
=
10
,
20
return
(
c
.
real
,
c
.
imag
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment