Skip to content
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

Flag add __all__/__none__ and eliminate _decompose() #1

Open
wants to merge 3 commits into
base: flag_small_refactor
Choose a base branch
from

Conversation

belm0
Copy link
Owner

@belm0 belm0 commented Nov 23, 2020

Proof of concept:

  • add __all__ class property, which is the composed flag value of all single bits
  • add __none__ class property, which is the flag value of no enabled bits
  • eliminate the heavy and complex internal _decompose() method by using the above attributes and efficient walking of enabled bits

changed behavior:

  • repr of multiple bits no longer includes compound items
    (e.g. given {RO = 0, WO = 1, RW = 2, AC = 3}, ~RO is RW|WO)

broken behavior:

  • "bizarre" flag enums which don't decompose into single-bit values
    (e.g. {B=3, C=4})
  • IntFlag invert, due to its one-to-many mapping to negative values

in its place, use __all__/__none__ class atributes and enabled-bit walking

Changed:
  * repr of multiple bits no longer includes compound items
    (given {RO = 0, WO = 1, RW = 2, AC = 3}, ~RO is RW|WO)

Broken:
  * "Bizarre" flag enums which don't decompose into single-bit values
    (e.g. {B=3, C=4})
  * IntFlag invert, due to its one-to-many mapping to negative values
belm0 pushed a commit that referenced this pull request Oct 5, 2021
```
Direct leak of 8 byte(s) in 1 object(s) allocated from:
    GH-0 0x7f008bf19667 in __interceptor_malloc (/lib64/libasan.so.6+0xb0667)
    GH-1 0x7f007a0bee4a in subprocess_fork_exec /home/heimes/dev/python/cpython/Modules/_posixsubprocess.c:774
    pythonGH-2 0xe0305b in cfunction_call Objects/methodobject.c:546
```

Signed-off-by: Christian Heimes <[email protected]>
(cherry picked from commit 0d3350d)

Co-authored-by: Christian Heimes <[email protected]>
belm0 pushed a commit that referenced this pull request Oct 5, 2021
* bpo-40791: Make compare_digest more constant-time.

The existing volatile `left`/`right` pointers guarantee that the reads will all occur, but does not guarantee that they will be _used_. So a compiler can still short-circuit the loop, saving e.g. the overhead of doing the xors and especially the overhead of the data dependency between `result` and the reads. That would change performance depending on where the first unequal byte occurs. This change removes that optimization.

(This is change GH-1 from https://bugs.python.org/issue40791 .)
(cherry picked from commit 3172936)

Co-authored-by: Devin Jeanpierre <[email protected]>
belm0 pushed a commit that referenced this pull request Feb 12, 2022
)

Fix test_gdb.test_pycfunction() for Python built with clang -Og.
Tolerate inlined functions in the gdb traceback.

When _testcapimodule.c is built by clang -Og, _null_to_none() is
inlined in meth_varargs() and so gdb returns _null_to_none() as
the frame #1. If it's not inlined, meth_varargs() is the frame #1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant