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
Boxiang Sun
cython
Commits
59840c9a
Commit
59840c9a
authored
Oct 10, 2008
by
didier deshommes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re: [Cython] cython doesn't compile cdef'd variables of type set?
parent
5ef2899e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
4 deletions
+54
-4
Cython/Compiler/Builtin.py
Cython/Compiler/Builtin.py
+6
-2
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+6
-2
tests/run/set.pyx
tests/run/set.pyx
+42
-0
No files found.
Cython/Compiler/Builtin.py
View file @
59840c9a
...
...
@@ -105,14 +105,18 @@ builtin_types_table = [
(
"keys"
,
"O"
,
"O"
,
"PyDict_Keys"
),
(
"values"
,
"O"
,
"O"
,
"PyDict_Values"
)]),
(
"set"
,
"PySet_Type"
,
[]),
(
"set"
,
"PySet_Type"
,
[(
"clear"
,
"O"
,
"i"
,
"PySet_Clear"
),
(
"discard"
,
"OO"
,
"i"
,
"PySet_Discard"
),
(
"add"
,
"OO"
,
"i"
,
"PySet_Add"
),
(
"pop"
,
"O"
,
"O"
,
"PySet_Pop"
)]),
(
"frozenset"
,
"PyFrozenSet_Type"
,
[]),
(
"slice"
,
"PySlice_Type"
,
[]),
(
"file"
,
"PyFile_Type"
,
[]),
]
builtin_structs_table
=
[
(
'Py_buffer'
,
'Py_buffer'
,
[(
"buf"
,
PyrexTypes
.
c_void_ptr_type
),
...
...
Cython/Compiler/PyrexTypes.py
View file @
59840c9a
...
...
@@ -6,7 +6,6 @@ import StringEncoding
import
Naming
import
copy
class
BaseType
:
#
# Base class for all Pyrex types including pseudo-types.
...
...
@@ -297,7 +296,12 @@ class BuiltinObjectType(PyObjectType):
return
type
.
is_pyobject
and
self
.
assignable_from
(
type
)
def
type_test_code
(
self
,
arg
):
return
'likely(Py%s_CheckExact(%s)) || (%s) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected %s, got %%s", Py_TYPE(%s)->tp_name), 0)'
%
(
self
.
name
[
0
].
upper
()
+
self
.
name
[
1
:],
arg
,
arg
,
self
.
name
,
arg
)
type
=
self
.
name
.
capitalize
()
if
type
==
'Set'
:
type
=
'AnySet'
elif
type
==
'Frozenset'
:
type
=
'FrozenSet'
return
'likely(Py%s_CheckExact(%s)) || (%s) == Py_None || (PyErr_Format(PyExc_TypeError, "Expected %s, got %%s", Py_TYPE(%s)->tp_name), 0)'
%
(
type
,
arg
,
arg
,
self
.
name
,
arg
)
def
declaration_code
(
self
,
entity_code
,
for_display
=
0
,
dll_linkage
=
None
,
pyrex
=
0
):
...
...
tests/run/set.pyx
0 → 100644
View file @
59840c9a
__doc__
=
u"""
>>> test_set_add()
set(['a', 1])
>>> test_set_clear()
set([])
>>> test_set_pop()
set([])
>>> test_set_discard()
set([233, '12'])
"""
def
test_set_add
():
cdef
set
s1
s1
=
set
([
1
])
s1
.
add
(
1
)
s1
.
add
(
'a'
)
s1
.
add
(
1
)
return
s1
def
test_set_clear
():
cdef
set
s1
s1
=
set
([
1
])
s1
.
clear
()
return
s1
def
test_set_pop
():
cdef
set
s1
s1
=
set
()
s1
.
add
(
'2'
)
two
=
s1
.
pop
()
return
s1
def
test_set_discard
():
cdef
set
s1
s1
=
set
()
s1
.
add
(
'12'
)
s1
.
add
(
3
)
s1
.
add
(
233
)
s1
.
discard
(
'3'
)
s1
.
discard
(
3
)
return
s1
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