Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
19db347a
Commit
19db347a
authored
Feb 26, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '91cd46' into refcounting
parents
58366391
91cd46b6
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
159 deletions
+102
-159
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+1
-0
src/runtime/float.cpp
src/runtime/float.cpp
+70
-70
src/runtime/int.cpp
src/runtime/int.cpp
+15
-15
test/integration/numpy_patch.patch
test/integration/numpy_patch.patch
+0
-74
test/tests/future_division.py
test/tests/future_division.py
+16
-0
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
19db347a
...
@@ -1873,6 +1873,7 @@ void setupBuiltins() {
...
@@ -1873,6 +1873,7 @@ void setupBuiltins() {
notimplemented_cls
->
giveAttr
(
"__repr__"
,
notimplemented_cls
->
giveAttr
(
"__repr__"
,
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
notimplementedRepr
,
STR
,
1
)));
new
BoxedFunction
(
FunctionMetadata
::
create
((
void
*
)
notimplementedRepr
,
STR
,
1
)));
notimplemented_cls
->
freeze
();
notimplemented_cls
->
freeze
();
notimplemented_cls
->
instances_are_nonzero
=
true
;
NotImplemented
=
new
(
notimplemented_cls
)
Box
();
NotImplemented
=
new
(
notimplemented_cls
)
Box
();
constants
.
push_back
(
NotImplemented
);
constants
.
push_back
(
NotImplemented
);
...
...
src/runtime/float.cpp
View file @
19db347a
This diff is collapsed.
Click to expand it.
src/runtime/int.cpp
View file @
19db347a
...
@@ -483,7 +483,7 @@ extern "C" Box* intAddInt(BoxedInt* lhs, BoxedInt* rhs) {
...
@@ -483,7 +483,7 @@ extern "C" Box* intAddInt(BoxedInt* lhs, BoxedInt* rhs) {
extern
"C"
Box
*
intAddFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
extern
"C"
Box
*
intAddFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
return
boxFloat
(
lhs
->
n
+
rhs
->
d
);
return
boxFloat
(
lhs
->
n
+
rhs
->
d
);
}
}
...
@@ -494,7 +494,7 @@ extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs) {
...
@@ -494,7 +494,7 @@ extern "C" Box* intAdd(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
add_i64_i64
(
lhs
->
n
,
rhs_int
->
n
);
return
add_i64_i64
(
lhs
->
n
,
rhs_int
->
n
);
}
else
if
(
rhs
->
cls
==
float_cls
)
{
}
else
if
(
PyFloat_Check
(
rhs
)
)
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
boxFloat
(
lhs
->
n
+
rhs_float
->
d
);
return
boxFloat
(
lhs
->
n
+
rhs_float
->
d
);
}
else
{
}
else
{
...
@@ -609,7 +609,7 @@ extern "C" Box* intDivInt(BoxedInt* lhs, BoxedInt* rhs) {
...
@@ -609,7 +609,7 @@ extern "C" Box* intDivInt(BoxedInt* lhs, BoxedInt* rhs) {
extern
"C"
Box
*
intDivFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
extern
"C"
Box
*
intDivFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
if
(
rhs
->
d
==
0
)
{
if
(
rhs
->
d
==
0
)
{
raiseExcHelper
(
ZeroDivisionError
,
"float divide by zero"
);
raiseExcHelper
(
ZeroDivisionError
,
"float divide by zero"
);
...
@@ -623,7 +623,7 @@ extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs) {
...
@@ -623,7 +623,7 @@ extern "C" Box* intDiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intDivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
return
intDivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
rhs
->
cls
==
float_cls
)
{
}
else
if
(
PyFloat_Check
(
rhs
)
)
{
return
intDivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
return
intDivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
}
else
{
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -650,7 +650,7 @@ extern "C" Box* intFloordivInt(BoxedInt* lhs, BoxedInt* rhs) {
...
@@ -650,7 +650,7 @@ extern "C" Box* intFloordivInt(BoxedInt* lhs, BoxedInt* rhs) {
extern
"C"
Box
*
intFloordivFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
extern
"C"
Box
*
intFloordivFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
if
(
rhs
->
d
==
0
)
{
if
(
rhs
->
d
==
0
)
{
raiseExcHelper
(
ZeroDivisionError
,
"float divide by zero"
);
raiseExcHelper
(
ZeroDivisionError
,
"float divide by zero"
);
...
@@ -665,7 +665,7 @@ extern "C" Box* intFloordiv(BoxedInt* lhs, Box* rhs) {
...
@@ -665,7 +665,7 @@ extern "C" Box* intFloordiv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intFloordivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
return
intFloordivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
rhs
->
cls
==
float_cls
)
{
}
else
if
(
PyFloat_Check
(
rhs
)
)
{
return
intFloordivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
return
intFloordivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
}
else
{
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -696,7 +696,7 @@ extern "C" Box* intTruedivInt(BoxedInt* lhs, BoxedInt* rhs) {
...
@@ -696,7 +696,7 @@ extern "C" Box* intTruedivInt(BoxedInt* lhs, BoxedInt* rhs) {
extern
"C"
Box
*
intTruedivFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
extern
"C"
Box
*
intTruedivFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
if
(
rhs
->
d
==
0
)
{
if
(
rhs
->
d
==
0
)
{
raiseExcHelper
(
ZeroDivisionError
,
"division by zero"
);
raiseExcHelper
(
ZeroDivisionError
,
"division by zero"
);
...
@@ -711,7 +711,7 @@ extern "C" Box* intTruediv(BoxedInt* lhs, Box* rhs) {
...
@@ -711,7 +711,7 @@ extern "C" Box* intTruediv(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
return
intTruedivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
return
intTruedivInt
(
lhs
,
static_cast
<
BoxedInt
*>
(
rhs
));
}
else
if
(
rhs
->
cls
==
float_cls
)
{
}
else
if
(
PyFloat_Check
(
rhs
)
)
{
return
intTruedivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
return
intTruedivFloat
(
lhs
,
static_cast
<
BoxedFloat
*>
(
rhs
));
}
else
{
}
else
{
return
incref
(
NotImplemented
);
return
incref
(
NotImplemented
);
...
@@ -751,7 +751,7 @@ extern "C" Box* intLShift(BoxedInt* lhs, Box* rhs) {
...
@@ -751,7 +751,7 @@ extern "C" Box* intLShift(BoxedInt* lhs, Box* rhs) {
raiseExcHelper
(
TypeError
,
"descriptor '__lshift__' requires a 'int' object but received a '%s'"
,
raiseExcHelper
(
TypeError
,
"descriptor '__lshift__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
rhs
->
cls
==
long_cls
)
if
(
PyLong_Check
(
rhs
)
)
return
longLShiftLong
(
autoDecref
(
boxLong
(
lhs
->
n
)),
rhs
);
return
longLShiftLong
(
autoDecref
(
boxLong
(
lhs
->
n
)),
rhs
);
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
...
@@ -847,7 +847,7 @@ extern "C" Box* intMulInt(BoxedInt* lhs, BoxedInt* rhs) {
...
@@ -847,7 +847,7 @@ extern "C" Box* intMulInt(BoxedInt* lhs, BoxedInt* rhs) {
extern
"C"
Box
*
intMulFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
extern
"C"
Box
*
intMulFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
return
boxFloat
(
lhs
->
n
*
rhs
->
d
);
return
boxFloat
(
lhs
->
n
*
rhs
->
d
);
}
}
...
@@ -858,7 +858,7 @@ extern "C" Box* intMul(BoxedInt* lhs, Box* rhs) {
...
@@ -858,7 +858,7 @@ extern "C" Box* intMul(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intMulInt
(
lhs
,
rhs_int
);
return
intMulInt
(
lhs
,
rhs_int
);
}
else
if
(
rhs
->
cls
==
float_cls
)
{
}
else
if
(
PyFloat_Check
(
rhs
)
)
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
intMulFloat
(
lhs
,
rhs_float
);
return
intMulFloat
(
lhs
,
rhs_float
);
}
else
{
}
else
{
...
@@ -896,7 +896,7 @@ extern "C" Box* intPowLong(BoxedInt* lhs, BoxedLong* rhs, Box* mod) {
...
@@ -896,7 +896,7 @@ extern "C" Box* intPowLong(BoxedInt* lhs, BoxedLong* rhs, Box* mod) {
extern
"C"
Box
*
intPowFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
,
Box
*
mod
)
{
extern
"C"
Box
*
intPowFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
,
Box
*
mod
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
if
(
mod
!=
None
)
{
if
(
mod
!=
None
)
{
raiseExcHelper
(
TypeError
,
"pow() 3rd argument not allowed unless all arguments are integers"
);
raiseExcHelper
(
TypeError
,
"pow() 3rd argument not allowed unless all arguments are integers"
);
...
@@ -964,7 +964,7 @@ extern "C" Box* intRShift(BoxedInt* lhs, Box* rhs) {
...
@@ -964,7 +964,7 @@ extern "C" Box* intRShift(BoxedInt* lhs, Box* rhs) {
raiseExcHelper
(
TypeError
,
"descriptor '__rshift__' requires a 'int' object but received a '%s'"
,
raiseExcHelper
(
TypeError
,
"descriptor '__rshift__' requires a 'int' object but received a '%s'"
,
getTypeName
(
lhs
));
getTypeName
(
lhs
));
if
(
rhs
->
cls
==
long_cls
)
if
(
PyLong_Check
(
rhs
)
)
return
longRShiftLong
(
autoDecref
(
boxLong
(
lhs
->
n
)),
rhs
);
return
longRShiftLong
(
autoDecref
(
boxLong
(
lhs
->
n
)),
rhs
);
if
(
!
PyInt_Check
(
rhs
))
{
if
(
!
PyInt_Check
(
rhs
))
{
...
@@ -994,7 +994,7 @@ extern "C" Box* intSubInt(BoxedInt* lhs, BoxedInt* rhs) {
...
@@ -994,7 +994,7 @@ extern "C" Box* intSubInt(BoxedInt* lhs, BoxedInt* rhs) {
extern
"C"
Box
*
intSubFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
extern
"C"
Box
*
intSubFloat
(
BoxedInt
*
lhs
,
BoxedFloat
*
rhs
)
{
assert
(
PyInt_Check
(
lhs
));
assert
(
PyInt_Check
(
lhs
));
assert
(
rhs
->
cls
==
float_cls
);
assert
(
PyFloat_Check
(
rhs
)
);
return
boxFloat
(
lhs
->
n
-
rhs
->
d
);
return
boxFloat
(
lhs
->
n
-
rhs
->
d
);
}
}
...
@@ -1005,7 +1005,7 @@ extern "C" Box* intSub(BoxedInt* lhs, Box* rhs) {
...
@@ -1005,7 +1005,7 @@ extern "C" Box* intSub(BoxedInt* lhs, Box* rhs) {
if
(
PyInt_Check
(
rhs
))
{
if
(
PyInt_Check
(
rhs
))
{
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
return
intSubInt
(
lhs
,
rhs_int
);
return
intSubInt
(
lhs
,
rhs_int
);
}
else
if
(
rhs
->
cls
==
float_cls
)
{
}
else
if
(
PyFloat_Check
(
rhs
)
)
{
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
BoxedFloat
*
rhs_float
=
static_cast
<
BoxedFloat
*>
(
rhs
);
return
intSubFloat
(
lhs
,
rhs_float
);
return
intSubFloat
(
lhs
,
rhs_float
);
}
else
{
}
else
{
...
...
test/integration/numpy_patch.patch
View file @
19db347a
diff --git a/numpy/__init__.py b/numpy/__init__.py
index d4ef54d..7a49dbd 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -196,7 +196,7 @@
else:
from . import linalg
from . import fft
from . import polynomial
- from . import random
+ # from . import random
from . import ctypeslib
from . import ma
from . import matrixlib as _mat
@@ -218,7 +218,8 @@
else:
__all__.extend(core.__all__)
__all__.extend(_mat.__all__)
__all__.extend(lib.__all__)
- __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
+ __all__.extend(['linalg', 'fft', 'ctypeslib', 'ma'])
+ # __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
# Filter annoying Cython warnings that serve no good purpose.
import warnings
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h
index fbaaeac..cb4adbb 100644
index fbaaeac..cb4adbb 100644
--- a/numpy/core/include/numpy/ndarrayobject.h
--- a/numpy/core/include/numpy/ndarrayobject.h
...
@@ -193,20 +170,6 @@ index 7797731..93edc66 100644
...
@@ -193,20 +170,6 @@ index 7797731..93edc66 100644
return NULL;
return NULL;
}
}
diff --git a/numpy/core/tests/test_function_base.py b/numpy/core/tests/test_function_base.py
index 2df7ba3..88fac0a 100644
--- a/numpy/core/tests/test_function_base.py
+++ b/numpy/core/tests/test_function_base.py
@@ -113,7 +113,8 @@
class TestLinspace(TestCase):
a = PhysicalQuantity(0.0)
b = PhysicalQuantity(1.0)
- assert_equal(linspace(a, b), linspace(0.0, 1.0))
+ # TODO: Need to support operations on inherited floats like divide.
+ # assert_equal(linspace(a, b), linspace(0.0, 1.0))
def test_denormal_numbers(self):
# Regression test for gh-5437. Will probably fail when compiled
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
index 7a18f29..a8d4e4b 100644
index 7a18f29..a8d4e4b 100644
--- a/numpy/core/tests/test_records.py
--- a/numpy/core/tests/test_records.py
...
@@ -282,40 +245,3 @@ index dba74d3..23cfeed 100644
...
@@ -282,40 +245,3 @@ index dba74d3..23cfeed 100644
def test_masked_array_repeat(self, level=rlevel):
def test_masked_array_repeat(self, level=rlevel):
# Ticket #271
# Ticket #271
diff --git a/numpy/random/setup.py b/numpy/random/setup.py
index 9d90590..b3ee24f 100644
--- a/numpy/random/setup.py
+++ b/numpy/random/setup.py
@@ -39,18 +39,6 @@
def configuration(parent_package='',top_path=None):
libs = []
# Configure mtrand
- config.add_extension('mtrand',
- sources=[join('mtrand', x) for x in
- ['mtrand.c', 'randomkit.c', 'initarray.c',
- 'distributions.c']]+[generate_libraries],
- libraries=libs,
- depends=[join('mtrand', '*.h'),
- join('mtrand', '*.pyx'),
- join('mtrand', '*.pxi'),],
- define_macros=defs,
- )
-
- config.add_data_files(('.', join('mtrand', 'randomkit.h')))
config.add_data_dir('tests')
return config
diff --git a/setup.py b/setup.py
index 90dcb24..943851a 100755
--- a/setup.py
+++ b/setup.py
@@ -245,7 +245,8 @@
def setup_package():
cwd = os.path.abspath(os.path.dirname(__file__))
if not os.path.exists(os.path.join(cwd, 'PKG-INFO')):
# Generate Cython sources, unless building from source release
- generate_cython()
+ # generate_cython()
+ pass
metadata['configuration'] = configuration
try:
test/tests/future_division.py
View file @
19db347a
...
@@ -22,3 +22,19 @@ test(-3.0, -2.0)
...
@@ -22,3 +22,19 @@ test(-3.0, -2.0)
test
(
1.0
+
1.0j
,
2
)
test
(
1.0
+
1.0j
,
2
)
test
(
1.0
+
1.0j
,
2.0
)
test
(
1.0
+
1.0j
,
2.0
)
test
(
1.0
+
1.0j
,
2.0j
)
test
(
1.0
+
1.0j
,
2.0j
)
class
PhysicalQuantity
(
float
):
def
__new__
(
cls
,
value
):
return
float
.
__new__
(
cls
,
value
)
def
__div__
(
self
,
x
):
print
(
'__div__ get called'
)
return
PhysicalQuantity
(
float
(
self
)
/
float
(
x
))
def
__rdiv__
(
self
,
x
):
print
(
'__rdiv__ get called'
)
return
PhysicalQuantity
(
float
(
x
)
/
float
(
self
))
a
=
PhysicalQuantity
(
2.0
)
print
(
a
/
3.0
)
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