Message157603
| Author |
Jimbofbx |
| Recipients |
Jimbofbx, Ramchandra Apte, jcea, serhiy.storchaka, skrah |
| Date |
2012年04月05日.16:33:17 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1333643598.75.0.708280665281.issue14478@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I presume you mean in 3.2? Have you looked at the source code for that decorator? It's fundamentally a try/except but with a lot more unnecessary bloat than is needed for caching a single int result from a function with no arguments. Its actually a lot slower.
If this is likely going to see use in 3.3 then it would probably just be a long int since 3.3 uses C. 0 would indicate uncalculated.
Hash function would have to be set up to never return 0.
Also every function would need to be tested to make sure there isn't any "in-place" modification of the Decimal object that could alter the hash value.
I like how the cached hash in 3.3 is faster than int for hashing. Shouldn't an int just return itself? Why would it be slower? |
|