Message283099
| Author |
serhiy.storchaka |
| Recipients |
methane, serhiy.storchaka, vstinner |
| Date |
2016年12月13日.13:06:58 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1481634421.56.0.985862767516.issue28959@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
In additional to C API functions PyTuple_Size() and PyList_Size() there are fast macros PyTuple_GET_SIZE() and PyList_GET_SIZE() for getting the size of a tuple or a list. But for dicts there is just PyDict_Size(). It is not just slower than a macro, but can return an error (actually this never happens in CPython core and extensions).
Proposed patch adds new private macro _PyDict_GET_SIZE() and makes the code using it instead of PyDict_Size(). I don't expect significant performance gain except perhaps few checks that a dict is empty. The main advantage to me is that not checking the result for error no longer looks as potential bug. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年12月13日 13:07:02 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, vstinner, methane |
| 2016年12月13日 13:07:01 | serhiy.storchaka | set | messageid: <1481634421.56.0.985862767516.issue28959@psf.upfronthosting.co.za> |
| 2016年12月13日 13:07:01 | serhiy.storchaka | link | issue28959 messages |
| 2016年12月13日 13:07:01 | serhiy.storchaka | create |
|