Skip to content

Count leading zero bits in one CPU tick #19633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 102 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
36b718d
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
5414a2f
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
9b30a64
Merge branch 'count_leading_zeros' of github.com:hnarkaytis/cpython i…
hnarkaytis Apr 21, 2020
7e982dc
Add support for _MSC_
hnarkaytis Apr 21, 2020
debeb02
Workaround _MCVC_ support
hnarkaytis Apr 21, 2020
9c82ea7
bpo-34037: Add Python API whatsnew for loop.shutdown_default_executor…
aeros Apr 21, 2020
d3a8d61
Small improvements to the recipes and examples. (GH-19635)
rhettinger Apr 21, 2020
75bedbe
bpo-40327: Improve atomicity, speed, and memory efficiency of the ite…
rhettinger Apr 21, 2020
783a673
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (GH-1…
ned-deily Apr 22, 2020
939e4c1
Workaround _MCVC_ inability to handle macro
hnarkaytis Apr 22, 2020
3a69f3c
bpo-38439: Add 256px IDLE icon (GH-17473)
hroncok Apr 22, 2020
b310700
bpo-38360: macOS: support alternate form of -isysroot flag (GH-16480)
jmroot Apr 22, 2020
bcc136b
bpo-38329: python.org macOS installers now update Current symlink (GH…
ned-deily Apr 22, 2020
9e2e2f3
Count leading zero bits with single CPU instruction
hnarkaytis Apr 22, 2020
22141ec
Replace __builtin_clz with __builtin_clzl
hnarkaytis Apr 22, 2020
886a15b
Change preprocessor check on ifdef MS_WINDOWS
hnarkaytis Apr 22, 2020
bd95e34
Add debug preprocessor check on ifdef MS_WINDOWS
hnarkaytis Apr 22, 2020
543e481
Fix typo and argument type
hnarkaytis Apr 22, 2020
9bee32b
bpo-40138: Fix Windows os.waitpid() for large exit code (GH-19637)
vstinner Apr 22, 2020
9b49893
bpo-40214: Fix ctypes WinDLL test with insecure flags (GH-19652)
zooba Apr 22, 2020
4454057
bpo-39562: Prevent collision of future and compiler flags (GH-19230)
isidentical Apr 22, 2020
39652cd
bpo-40260: Remove unnecessary newline in compile() call (GH-19641)
asottile Apr 22, 2020
a81849b
bpo-39939: Add str.removeprefix and str.removesuffix (GH-18939)
sweeneyde Apr 22, 2020
c5fc156
bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)
pablogsal Apr 22, 2020
3f8a58b
PEP 617: Only run the CI with the new parser (GH-19664)
pablogsal Apr 22, 2020
458004b
bpo-40334: Fix errors in parse_string.c with old compilers (GH-19666)
pablogsal Apr 22, 2020
ce0eacb
Add @pablogsal as code owner for pegen-related files (GH-19665)
pablogsal Apr 22, 2020
a25f3c4
bpo-40334: Fix builds outside the source directory and regenerate aut…
pablogsal Apr 23, 2020
1def775
bpo-40334: Rename PyConfig.use_peg to _use_peg_parser (GH-19670)
vstinner Apr 23, 2020
0b7829e
Compile extensions in test_peg_generator with C99 (GH-19668)
pablogsal Apr 23, 2020
ee40e4b
bpo-40334: Don't downcast from Py_ssize_t to int (GH-19671)
pablogsal Apr 23, 2020
1df5a9e
bpo-40334: Fix build errors and warnings in test_peg_generator (GH-19…
pablogsal Apr 23, 2020
8d1cbff
bpo-40334: Suppress all output in test_peg_generator (GH-19675)
lysnikolaou Apr 23, 2020
1221135
gdbinit: Use proper define syntax (GH-19557)
The-Compiler Apr 23, 2020
9e6a131
bpo-40370: Use the same compile and link args as the interpreter used…
pablogsal Apr 23, 2020
ebebb64
bpo-40334: Improve various PEG-Parser related stuff (GH-19669)
lysnikolaou Apr 23, 2020
02e4484
Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-…
corona10 Apr 23, 2020
d663d34
bpo-39983: Add test.support.print_warning() (GH-19683)
vstinner Apr 23, 2020
40ded94
bpo-40336: Refactor typing._SpecialForm (GH-19620)
serhiy-storchaka Apr 23, 2020
bc28805
bpo-40334: Use old compiler when compile mode is func_type (GH-19692)
gvanrossum Apr 23, 2020
3e89251
Fix broken mkdir -p call in regen-pegen (#19695)
gvanrossum Apr 23, 2020
50f28de
bpo-40334: Allow to run make regen-pegen without distutils (GH-19684)
pablogsal Apr 23, 2020
9f27dd3
Use Py_ssize_t instead of ssize_t (GH-19685)
pablogsal Apr 24, 2020
2510494
bpo-40048: Fix _PyCode_InitOpcache() error path (GH-19691)
vstinner Apr 24, 2020
4cc4d60
Expand the implementation comments (GH-19699)
rhettinger Apr 24, 2020
162c567
bpo-38061: os.closerange() uses closefrom() on FreeBSD (GH-19696)
vstinner Apr 24, 2020
e6f8abd
bpo-38061: subprocess uses closefrom() on FreeBSD (GH-19697)
vstinner Apr 24, 2020
24ffe70
bpo-40334: Rewrite test_c_parser to avoid memory leaks (GH-19694)
lysnikolaou Apr 24, 2020
503de71
bpo-40360: Deprecate lib2to3 module in light of PEP 617 (GH-19663)
carljm Apr 24, 2020
5aafa54
bpo-40340: Separate examples more clearly in the programming FAQ (GH-…
caje731 Apr 24, 2020
0e80b56
bpo-40334: Add What's New sections for PEP 617 and PEP 585 (GH-19704)
gvanrossum Apr 25, 2020
f828077
closes bpo-40385: Remove Tools/scripts/checkpyc.py (GH-19709)
ammaraskar Apr 25, 2020
d4f3923
bpo-40279: Add some error-handling to the module initialisation docs …
caje731 Apr 25, 2020
3c8a5b4
bpo-40275: Avoid importing asyncio in test.support (GH-19600)
serhiy-storchaka Apr 25, 2020
1699491
bpo-40275: Avoid importing socket in test.support (GH-19603)
serhiy-storchaka Apr 25, 2020
515fce4
bpo-40275: Avoid importing logging in test.support (GH-19601)
serhiy-storchaka Apr 25, 2020
ef33712
Fix typo in object.__format__ docs (GH-19504)
hroskes Apr 26, 2020
cfaf4c0
Fix typo in Lib/typing.py (GH-19717)
nfishe Apr 26, 2020
68b352a
bpo-40396: Support GenericAlias in the typing functions. (GH-19718)
serhiy-storchaka Apr 26, 2020
88499f1
bpo-40387: Improve queue join() example. (GH-19724)
rhettinger Apr 27, 2020
a494caa
bpo-40401: Remove duplicate pyhash.h include from pythoncore.vcxproj …
ammaraskar Apr 27, 2020
b54e46c
bpo-38387: Formally document PyDoc_STRVAR and PyDoc_STR macros (GH-16…
bsolomon1124 Apr 27, 2020
caf1aad
bpo-40348: Fix typos in the programming FAQ (GH-19729)
ZackerySpytz Apr 27, 2020
6292be7
bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)
serhiy-storchaka Apr 27, 2020
4044c84
Add files in tests/test_peg_generator to the install target lists (GH…
pablogsal Apr 27, 2020
0169d30
bpo-40217: Ensure Py_VISIT(Py_TYPE(self)) is always called for PyType…
pablogsal Apr 27, 2020
91a5ae1
bpo-40217: Clean code in PyType_FromSpec_Alloc and add NEWS entry (GH…
pablogsal Apr 27, 2020
c5c4281
bpo-40375: Implement imaplib.IMAP4.unselect (GH-19712)
corona10 Apr 27, 2020
9adccc1
bpo-30966: Add multiprocessing.SimpleQueue.close() (GH-19735)
vstinner Apr 27, 2020
2b74c83
bpo-40334: Support CO_FUTURE_BARRY_AS_BDFL in the new parser (GH-19721)
pablogsal Apr 27, 2020
b94dbd7
bpo-40334: Support PyPARSE_DONT_IMPLY_DEDENT in the new parser (GH-19…
pablogsal Apr 27, 2020
1a27501
bpo-30966: concurrent.futures.Process.shutdown() closes queue (GH-19738)
vstinner Apr 27, 2020
5d1f32d
bpo-39995: Split test_concurrent_futures.test_crash() into sub-tests …
vstinner Apr 27, 2020
bc1c8af
Python 3.9.0a6
ambv Apr 27, 2020
d55133f
bpo-40334: Catch E_EOF error, when the tokenizer returns ERRORTOKEN (…
lysnikolaou Apr 28, 2020
3d53d87
bpo-40334: Don't skip test_parser:test_trigget_memory_error (GH-19744)
lysnikolaou Apr 28, 2020
5b9f498
bpo-40334: Refactor peg_generator to receive a Tokens file when build…
pablogsal Apr 28, 2020
d66685a
Merge tag 'v3.9.0a6'
ambv Apr 28, 2020
5da3526
Post 3.9.0a6
ambv Apr 28, 2020
7c59d7c
bpo-40421: Add pyframe.h header file (GH-19755)
vstinner Apr 28, 2020
b8f704d
bpo-40421: Add Include/cpython/code.h header file (GH-19756)
vstinner Apr 28, 2020
a42ca74
bpo-40421: Add PyFrame_GetCode() function (GH-19757)
vstinner Apr 28, 2020
d9a43e2
bpo-40025: Require _generate_next_value_ to be defined before members…
abbyonstott Apr 28, 2020
521c8d6
bpo-39966: Revert "bpo-25597: Ensure wraps' return value is used for …
tirkarthi Apr 28, 2020
6d86a23
bpo-40429: PyFrame_GetCode() result cannot be NULL (GH-19772)
vstinner Apr 28, 2020
5e8c691
bpo-32604: Add support for a "default" arg in channel_recv(). (GH-19770)
ericsnowcurrently Apr 28, 2020
8852ad4
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
vstinner Apr 28, 2020
49f70db
bpo-40431: Fix syntax typo in turtledemo (GH-19777)
hroncok Apr 29, 2020
f7bbf58
bpo-38880: List interpreters associated with a channel end (GH-17323)
LewisGaul Apr 29, 2020
cc0dc7e
bpo-40429: Refactor super_init() (GH-19776)
vstinner Apr 29, 2020
ae00a5a
bpo-40428: Remove PyTuple_ClearFreeList() function (GH-19769)
vstinner Apr 29, 2020
37af21b
bpo-40334: Fix shifting of nested f-strings in the new parser (GH-19771)
lysnikolaou Apr 29, 2020
4386b90
bpo-40429: PyThreadState_GetFrame() returns a strong ref (GH-19781)
vstinner Apr 29, 2020
2208134
bpo-40334: Explicitly cast to int in pegen.c to fix a compiler warnin…
pablogsal Apr 29, 2020
66abe98
bpo-40275: Move requires_hashdigest() to test.support.hashlib_helper …
shihai1991 Apr 29, 2020
7036477
bpo-40421: Add PyFrame_GetBack() function (GH-19765)
vstinner Apr 29, 2020
a4dfe8e
bpo-39995: Fix concurrent.futures _ThreadWakeup (GH-19760)
vstinner Apr 29, 2020
6d65087
bpo-40334: Disallow invalid single statements in the new parser (GH-1…
lysnikolaou Apr 29, 2020
bb4a585
bpo-40428: Remove references to Py*_ClearFreeList in the docs (GH-19783)
ZackerySpytz Apr 29, 2020
8f36fda
Count leading zero bits in one CPU tick
hnarkaytis Apr 21, 2020
64ecf0d
Rebase to master
hnarkaytis Apr 29, 2020
2908911
Cleanup merge conflict artifacts
hnarkaytis Apr 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions Python/pymath.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ round(double x)
}
#endif /* HAVE_ROUND */

static const unsigned int BitLengthTable[32] = {
0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
};

unsigned int _Py_bit_length(unsigned long d) {
unsigned int d_bits = 0;
while (d >= 32) {
d_bits += 6;
d >>= 6;
}
d_bits += BitLengthTable[d];
return d_bits;
return d ? __CHAR_BIT__ * sizeof (d) - __builtin_clz (d) : 0;
}