Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Kirill Smelkov
cpython
Commits
cc74b6ab
Commit
cc74b6ab
authored
Apr 10, 2012
by
Stefan Krah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14478: Cache the hash of a Decimal in the C version.
parent
9deb1887
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
Modules/_decimal/_decimal.c
Modules/_decimal/_decimal.c
+14
-1
No files found.
Modules/_decimal/_decimal.c
View file @
cc74b6ab
...
...
@@ -60,6 +60,7 @@
typedef
struct
{
PyObject_HEAD
Py_hash_t
hash
;
mpd_t
dec
;
mpd_uint_t
data
[
_Py_DEC_MINALLOC
];
}
PyDecObject
;
...
...
@@ -1805,6 +1806,8 @@ PyDecType_New(PyTypeObject *type)
return
NULL
;
}
dec
->
hash
=
-
1
;
MPD
(
dec
)
->
flags
=
MPD_STATIC
|
MPD_STATIC_DATA
;
MPD
(
dec
)
->
exp
=
0
;
MPD
(
dec
)
->
digits
=
0
;
...
...
@@ -4210,7 +4213,7 @@ dec_floor(PyObject *self, PyObject *dummy UNUSED)
/* Always uses the module context */
static
Py_hash_t
dec_hash
(
Py
Object
*
v
)
_dec_hash
(
PyDec
Object
*
v
)
{
#if defined(CONFIG_64) && _PyHASH_BITS == 61
/* 2**61 - 1 */
...
...
@@ -4323,6 +4326,16 @@ malloc_error:
goto
finish
;
}
static
Py_hash_t
dec_hash
(
PyDecObject
*
self
)
{
if
(
self
->
hash
==
-
1
)
{
self
->
hash
=
_dec_hash
(
self
);
}
return
self
->
hash
;
}
/* __reduce__ */
static
PyObject
*
dec_reduce
(
PyObject
*
self
,
PyObject
*
dummy
UNUSED
)
...
...
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