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
Kirill Smelkov
cython
Commits
320fa6d7
Commit
320fa6d7
authored
Jan 05, 2021
by
Robert Bradshaw
Committed by
GitHub
Jan 05, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3962 from da-woods/string_to_float
Always use "new" string->float conversions
parents
e6f92c17
0a3cc077
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-0
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+0
-1
Cython/Utility/TypeConversion.c
Cython/Utility/TypeConversion.c
+23
-1
No files found.
Cython/Compiler/Optimize.py
View file @
320fa6d7
...
...
@@ -2195,6 +2195,7 @@ class OptimizeBuiltinCalls(Visitor.NodeRefCleanupMixin,
args
=
[
func_arg
],
py_name
=
'float'
,
is_temp
=
node
.
is_temp
,
utility_code
=
UtilityCode
.
load_cached
(
"pynumber_float"
,
"TypeConversion.c"
),
result_is_used
=
node
.
result_is_used
,
).
coerce_to
(
node
.
type
,
self
.
current_env
())
return
node
...
...
Cython/Utility/Optimize.c
View file @
320fa6d7
...
...
@@ -713,7 +713,6 @@ static double __Pyx_SlowPyString_AsDouble(PyObject *obj) {
static
const
char
*
__Pyx__PyBytes_AsDouble_Copy
(
const
char
*
start
,
char
*
buffer
,
Py_ssize_t
length
)
{
Py_ssize_t
i
;
char
*
digit
=
buffer
;
for
(
i
=
0
;
i
<
length
;
i
++
)
{
if
(
start
[
i
]
!=
'_'
)
*
buffer
++
=
start
[
i
];
}
...
...
Cython/Utility/TypeConversion.c
View file @
320fa6d7
...
...
@@ -126,7 +126,8 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#else
#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
#endif
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
// __Pyx_PyNumber_Float is now in it's own section since it has dependencies (needed to make
// string conversion work the same in all circumstances)
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static
int
__Pyx_sys_getdefaultencoding_not_ascii
;
...
...
@@ -463,6 +464,27 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
return
PyInt_FromSize_t
(
ival
);
}
/////////////// pynumber_float.proto ///////////////
static
CYTHON_INLINE
PyObject
*
__Pyx__PyNumber_Float
(
PyObject
*
obj
);
/* proto */
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : __Pyx__PyNumber_Float(x))
/////////////// pynumber_float ///////////////
//@requires: Optimize.c::pybytes_as_double
//@requires: Optimize.c::pyunicode_as_double
static
CYTHON_INLINE
PyObject
*
__Pyx__PyNumber_Float
(
PyObject
*
obj
)
{
// obj is PyFloat is handled in the calling macro
if
(
PyUnicode_CheckExact
(
obj
))
{
return
PyFloat_FromDouble
(
__Pyx_PyUnicode_AsDouble
(
obj
));
}
else
if
(
PyBytes_CheckExact
(
obj
))
{
return
PyFloat_FromDouble
(
__Pyx_PyBytes_AsDouble
(
obj
));
}
else
if
(
PyByteArray_CheckExact
(
obj
))
{
return
PyFloat_FromDouble
(
__Pyx_PyByteArray_AsDouble
(
obj
));
}
else
{
return
PyNumber_Float
(
obj
);
}
}
/////////////// GCCDiagnostics.proto ///////////////
...
...
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