bip-0352: Refactor logical checks to improve readability in reference.py #1796

pull Pronoss wants to merge 1 commits into bitcoin:master from Pronoss:fix/update changing 1 files +8 −8
  1. Pronoss commented at 10:36 am on March 22, 2025: none

    This pull request refactors the logical checks in reference.py to enhance code readability and follow best practices in Python. Specifically:

    • Replaced bitwise & with logical and in conditional checks.
    • Simplified list length checks by using Pythonic if input_pub_keys: instead of if len(input_pub_keys) > 0.

    These changes improve the clarity and consistency of the code while maintaining its functionality.

    Changes

    • Replaced & with and for logical operations in several conditional checks.
    • Replaced if len(input_pub_keys) > 0 with if input_pub_keys to check for non-empty lists.
  2. Update reference.py 44c0ce0dea
  3. Pronoss renamed this:
    Refactor logical checks to improve readability
    bip-0352: Refactor logical checks to improve readability in `reference.py`
    on Mar 22, 2025
  4. jonatack added the label Proposed BIP modification on Mar 24, 2025
  5. jonatack added the label Pending acceptance on Mar 24, 2025
  6. jonatack commented at 7:04 pm on March 24, 2025: member
    I am not sure if this is an improvement worthy of requesting review time from the BIP authors.
  7. CitrixLab commented at 7:29 am on March 25, 2025: none
    This pull request refactors the code in reference.py by replacing the bitwise & operator with the logical and operator in conditional checks, which improves clarity and adheres to Python best practices, and by simplifying list length checks from using if len(input_pub_keys) > 0: to the more Pythonic if input_pub_keys:, thereby making the code cleaner and more readable while keeping its functionality intact.
  8. murchandamus commented at 3:36 pm on March 27, 2025: contributor

    The main purpose of reference implementations is to demonstrate the logic, rather than to adhere to the conventions of the language. E.g., it may be the motivation of the authors to specifically convey that they are focused on the number of items for witness stack and public keys rather than the object just being truthy.

    I’m more open to the replacement of the bitwise and with the logical and, but it seems rather minor, probably not worth bugging the authors over.

  9. murchandamus commented at 3:42 pm on March 27, 2025: contributor
    The authors don’t seem to be interested in this getting merged.
  10. murchandamus closed this on Mar 27, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-03-29 07:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me