GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Count leading zero bits in one CPU tick by hnarkaytis · Pull Request #19633 · python/cpython

Conversation

@hnarkaytis

@hnarkaytis hnarkaytis commented Apr 21, 2020

Copy link
Copy Markdown

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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hnarkaytis
Count leading zero bits in one CPU tick
36b718d
@the-knights-who-say-ni

the-knights-who-say-ni commented Apr 21, 2020

Copy link
Copy Markdown

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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Apr 21, 2020
@bedevere-bot bedevere-bot added the awaiting review label Apr 21, 2020
remilapeyre
remilapeyre reviewed Apr 21, 2020
View reviewed changes

@remilapeyre remilapeyre left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

isidentical and mdickinson reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
hnarkaytis added 4 commits April 21, 2020 19:53
@hnarkaytis
Count leading zero bits in one CPU tick
5414a2f
@hnarkaytis
Merge branch 'count_leading_zeros' of github.com:hnarkaytis/cpython i…
9b30a64
…nto count_leading_zeros
@hnarkaytis
Add support for _MSC_
7e982dc
@hnarkaytis
Workaround _MCVC_ support
debeb02
@mdickinson

mdickinson commented Apr 21, 2020

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mdickinson
mdickinson reviewed Apr 21, 2020
View reviewed changes
Comment thread Python/pymath.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

aeros and others added 13 commits April 21, 2020 16:50
@aeros @vstinner
bpo-34037: Add Python API whatsnew for loop.shutdown_default_executor…
9c82ea7
…() (python#19634)

Co-Authored-By: Victor Stinner <[email protected]>
@rhettinger
Small improvements to the recipes and examples. (pythonGH-19635)
d3a8d61
* 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
@rhettinger
bpo-40327: Improve atomicity, speed, and memory efficiency of the ite…
75bedbe
…ms() loop (pythonGH-19628)
@ned-deily
bpo-40164: Update macOS installer builds to use OpenSSL 1.1.1g. (pyth…
783a673
…onGH-19642)
@hnarkaytis
Workaround _MCVC_ inability to handle macro
939e4c1
@hroncok
bpo-38439: Add 256px IDLE icon (pythonGH-17473)
3a69f3c
Icon author: Andrew Clover, bpo-1490384
@jmroot @ned-deily
bpo-38360: macOS: support alternate form of -isysroot flag (pythonGH-…
b310700
…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 <[email protected]>
@ned-deily
bpo-38329: python.org macOS installers now update Current symlink (py…
bcc136b
…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.
@hnarkaytis
Count leading zero bits with single CPU instruction
9e2e2f3
@hnarkaytis
Replace __builtin_clz with __builtin_clzl
22141ec
@hnarkaytis
Change preprocessor check on ifdef MS_WINDOWS
886a15b
@hnarkaytis
Add debug preprocessor check on ifdef MS_WINDOWS
bd95e34
@hnarkaytis
Fix typo and argument type
543e481
@mdickinson

mdickinson commented Apr 22, 2020

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hnarkaytis

hnarkaytis commented Apr 22, 2020

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mdickinson

mdickinson commented Apr 22, 2020

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner and others added 3 commits April 22, 2020 16:30
@vstinner
bpo-40138: Fix Windows os.waitpid() for large exit code (pythonGH-19637)
9bee32b
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.
@zooba
bpo-40214: Fix ctypes WinDLL test with insecure flags (pythonGH-19652)
9b49893
@isidentical
bpo-39562: Prevent collision of future and compiler flags (pythonGH-1…
4454057
…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
@lysnikolaou @pablogsal
bpo-40334: Disallow invalid single statements in the new parser (pyth…
6d65087
…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 <[email protected]>
@ZackerySpytz
bpo-40428: Remove references to Py*_ClearFreeList in the docs (python…
bb4a585
…GH-19783)

They were removed from the C API in commit
ae00a5a.
@hnarkaytis
Count leading zero bits in one CPU tick
8f36fda
@hnarkaytis
Rebase to master
64ecf0d
@hnarkaytis
hnarkaytis requested review from a team, 1st1, asvetlov, berkerpeksag, brettcannon, encukou, ericsnowcurrently, ethanfurman, gpshead, gvanrossum, ilevkivskyi, methane, ncoghlan, pablogsal, rhettinger, terryjreedy, tiran, vsajip and warsaw as code owners April 29, 2020 05:14
@hnarkaytis
Cleanup merge conflict artifacts
2908911
@hnarkaytis
hnarkaytis marked this pull request as draft April 29, 2020 06:26
@ned-deily

ned-deily commented Apr 29, 2020

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hnarkaytis

hnarkaytis commented Apr 29, 2020

Copy link
Copy Markdown
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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@terryjreedy terryjreedy closed this Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@1st1 1st1 Awaiting requested review from 1st1
@asvetlov asvetlov Awaiting requested review from asvetlov
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@brettcannon brettcannon Awaiting requested review from brettcannon
@encukou encukou Awaiting requested review from encukou
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently
@ethanfurman ethanfurman Awaiting requested review from ethanfurman
@gpshead gpshead Awaiting requested review from gpshead
@gvanrossum gvanrossum Awaiting requested review from gvanrossum
@ilevkivskyi ilevkivskyi Awaiting requested review from ilevkivskyi
@methane methane Awaiting requested review from methane
@ncoghlan ncoghlan Awaiting requested review from ncoghlan
@pablogsal pablogsal Awaiting requested review from pablogsal
@rhettinger rhettinger Awaiting requested review from rhettinger
@terryjreedy terryjreedy Awaiting requested review from terryjreedy
@tiran tiran Awaiting requested review from tiran
@vsajip vsajip Awaiting requested review from vsajip
@warsaw warsaw Awaiting requested review from warsaw
2 more reviewers
@mdickinson mdickinson mdickinson left review comments
@remilapeyre remilapeyre remilapeyre left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

20 participants

@hnarkaytis @the-knights-who-say-ni @mdickinson @ned-deily @remilapeyre @terryjreedy @bedevere-bot @aeros @rhettinger @hroncok @jmroot @vstinner @zooba @isidentical @asottile @sweeneyde @pablogsal @lysnikolaou @The-Compiler @corona10
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.