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
c7f4ce39
Commit
c7f4ce39
authored
Nov 01, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test __new__() optimisation interaction with __cinit__()
parent
a32b90c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
tests/run/tp_new.pyx
tests/run/tp_new.pyx
+15
-0
No files found.
tests/run/tp_new.pyx
View file @
c7f4ce39
...
...
@@ -2,18 +2,27 @@
cimport
cython
cdef
class
MyType
:
def
__cinit__
(
self
):
print
"CINIT"
def
__init__
(
self
):
print
"INIT"
cdef
class
MySubType
(
MyType
):
def
__cinit__
(
self
):
print
"CINIT(SUB)"
def
__init__
(
self
):
print
"INIT"
class
MyClass
(
object
):
def
__cinit__
(
self
):
print
"CINIT"
def
__init__
(
self
):
print
"INIT"
class
MyTypeSubClass
(
MyType
):
def
__cinit__
(
self
):
# not called: Python class!
print
"CINIT(PYSUB)"
def
__init__
(
self
):
print
"INIT"
...
...
@@ -24,6 +33,7 @@ class MyTypeSubClass(MyType):
def
make_new
():
"""
>>> isinstance(make_new(), MyType)
CINIT
True
"""
m
=
MyType
.
__new__
(
MyType
)
...
...
@@ -34,6 +44,7 @@ def make_new():
def
make_new_typed_target
():
"""
>>> isinstance(make_new_typed_target(), MyType)
CINIT
True
"""
cdef
MyType
m
...
...
@@ -70,6 +81,7 @@ def make_new_none(type t=None):
def
make_new_pyclass
():
"""
>>> isinstance(make_new_pyclass(), MyTypeSubClass)
CINIT
True
"""
m
=
MyClass
.
__new__
(
MyClass
)
...
...
@@ -81,10 +93,13 @@ def make_new_pyclass():
def
make_new_args
(
type
t1
=
None
,
type
t2
=
None
):
"""
>>> isinstance(make_new_args(), MyType)
CINIT
True
>>> isinstance(make_new_args(MyType), MyType)
CINIT
True
>>> isinstance(make_new_args(MyType, MyType), MyType)
CINIT
True
>>> isinstance(make_new_args(MyType, MySubType), MySubType)
...
...
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