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

Conversation

hnarkaytis
Copy link

Count of leading bits was implemented as a CPU instructing 6 years ago. It doesn't make sense to have custom code for this.
https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_(Advanced_Bit_Manipulation)

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@hnarkaytis

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Copy link
Contributor

@remilapeyre remilapeyre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supported on all architecture that Python support (https://www.python.org/download/other/)?
What about CPU that don't have this instruction or where this instruction is slower?
Also this would need to be compatible with all compilers supported by CPython.

@mdickinson
Copy link
Member

Python runs on many different platforms and architectures. It's written (mostly) in standard C (specifically, C89, but with some C99 features permitted). __builtin_clz is not part of standard C.

It's okay to have platform-specific code when there's a good reason for it, but there will still need to be fallback code for platforms that don't have __builtin_clz available: we can't simply assume that it'll be available on any non-Windows platform.

aeros and others added 13 commits April 21, 2020 16:50
…() (python#19634)

Co-Authored-By: Victor Stinner <vstinner@python.org>
* Add underscores to long numbers to improve readability
* Use bigger dataset in the bootstrapping example
* Convert single-server queue example to more useful multi-server queue
Icon author: Andrew Clover, bpo-1490384
…16480)

It is possible to use either '-isysroot /some/path' (with a space) or
'-isysroot/some/path' (no space in between). Support both forms in
places where special handling of -isysroot is done, rather than just
the first form.
Co-authored-by: Ned Deily <nad@python.org>
…thonGH-19650)

Previously, python.org macOS installers did not alter the Current version
symlink in /Library/Frameworks/Python.framework/Versions when installing
a version of Python 3.x, only when installing 2.x.  Now that Python 2 is
retired, it's time to change that.  This should make it a bit easier
to embed Python 3 into other macOS applications.
@mdickinson
Copy link
Member

@hnarkaytis Thanks for the contribution. If you want to pursue this further, there are a couple of steps you need to take:

  • Please could you open a corresponding issue on the bug tracker (https://bugs.python.org/)? At the moment, we don't use GitHub issues, so bugs.python.org is where any related discussion should take place.
  • Please sign the CLA agreement (see the automated messages above) if you haven't done so already.

See the Python Developer's Guide for more detailed information and guidelines on contributing to core Python.

@hnarkaytis
Copy link
Author

@mdickinson let me take care of this.
I will extend configure for __builtin_clzl autodetection and will add fallback implementation for outdated compilers.

HHN.

@hnarkaytis Thanks for the contribution. If you want to pursue this further, there are a couple of steps you need to take:

  • Please could you open a corresponding issue on the bug tracker (https://bugs.python.org/)? At the moment, we don't use GitHub issues, so bugs.python.org is where any related discussion should take place.
  • Please sign the CLA agreement (see the automated messages above) if you haven't done so already.

See the Python Developer's Guide for more detailed information and guidelines on contributing to core Python.

@mdickinson
Copy link
Member

See also https://bugs.python.org/issue29782 and PR #594.

vstinner and others added 3 commits April 22, 2020 16:30
Fix the Windows implementation of os.waitpid() for exit code
larger than "INT_MAX >> 8". The exit status is now interpreted as an
unsigned number.

os.waitstatus_to_exitcode() now accepts wait status larger than
INT_MAX.
…9230)

The constant values of future flags in the __future__ module
is updated in order to prevent collision with compiler flags.
Previously PyCF_ALLOW_TOP_LEVEL_AWAIT was clashing
with CO_FUTURE_DIVISION.
lysnikolaou and others added 4 commits April 29, 2020 02:42
…onGH-19774)

After parsing is done in single statement mode, the tokenizer buffer has to be checked for additional lines and a `SyntaxError` must be raised, in case there are any.

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@hnarkaytis hnarkaytis marked this pull request as draft April 29, 2020 06:26
@ned-deily
Copy link
Member

@hnarkaytis, sorry but if you want anyone to review your suggestions, you need to follow our process as @mdickinson explained. And you need to redo this PR so it is against the current top of the master branch only, such that it only shows the actual changes you propose, not all the merges in 372 files.

@hnarkaytis
Copy link
Author

@hnarkaytis, sorry but if you want anyone to review your suggestions, you need to follow our process as @mdickinson explained. And you need to redo this PR so it is against the current top of the master branch only, such that it only shows the actual changes you propose, not all the merges in 372 files.

Yeah - I know. Just pushed code first. Will get the rest shortly. I converted pull request to draft, so it should not trigger anyone in review list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.