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 — Make implicit boolean conversions explicit · Issue #106008 · python/cpython

Make implicit boolean conversions explicit #106008

New issue
Copy link
New issue
Copy link
Closed
Closed
Make implicit boolean conversions explicit#106008
Copy link
Assignees
brandtbucher
Labels
3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Description

@brandtbucher
brandtbucher
opened on Jun 23, 2023
Issue body actions

...as discussed in faster-cpython/ideas#568.

By adding a dedicated instruction for converting values to bool, we can easily specialize the conditions of all remaining branches in the bytecode while keeping the branches themselves as "dumb" and simple as possible.

This is one of the few remaining common cases where a little specilization will give us a lot of useful information (such as "this branch won't execute arbitrary code") for higher tiers of optimization. Plus, the most common specializations (such as for bool or None) will be effectively no-ops.

Linked PRs

  • GH-106008: Make implicit boolean conversions explicit #106003
  • GH-106008: Fix refleak when peepholing None comparisons #106367
Reacted by sunmy2019

Activity

  1. brandtbucher
    added
    performancePerformance or resource usagePerformance or resource usage
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    3.13only security fixesonly security fixes
    on Jun 23, 2023
  2. brandtbucher
    self-assigned this
    on Jun 23, 2023
  3. brandtbucher
    added a commit that references this issue on Jun 29, 2023

    GH-106008: Make implicit boolean conversions explicit (GH-106003)

    7b2d94d
  4. brandtbucher
    closed this as completedon Jun 29, 2023
  5. pablogsal commented on Jul 3, 2023

    @pablogsal
    pablogsal
    on Jul 3, 2023
    Member
    More actions

    @brandtbucher Apparently this PR introduced a refleak in test_grammar:

    Raised RLIMIT_NOFILE: 256 -> 1024
    0:00:00 load avg: 14.52 Run tests sequentially
    0:00:00 load avg: 14.52 [1/1] test_grammar
    beginning 9 repetitions
    123456789
    .........
    test_grammar leaked [2, 2, 2, 2] references, sum=8
    test_grammar leaked [2, 2, 2, 2] memory blocks, sum=8
    test_grammar failed (reference leak)
    
    == Tests result: FAILURE ==
    
    1 test failed:
        test_grammar
    
    Total duration: 349 ms
    Tests result: FAILURE
    

    The previous commit builds correctly:

    ❯ git checkout HEAD^
    Previous HEAD position was 7b2d94d8751 GH-106008: Make implicit boolean conversions explicit (GH-106003)
    HEAD is now at 6e9f83d9aee GH-106250: Support insts using one cache entry and no oparg (GH-106252)
    
    ❯ make -j -s
    ...
    
    ❯ ./python.exe -m test test_grammar -R :
    Raised RLIMIT_NOFILE: 256 -> 1024
    0:00:00 load avg: 11.57 Run tests sequentially
    0:00:00 load avg: 11.57 [1/1] test_grammar
    beginning 9 repetitions
    123456789
    .........
    
    == Tests result: SUCCESS ==
    
    1 test OK.
    
    Total duration: 342 ms
    Tests result: SUCCESS
    

    can you take a look?

  6. brandtbucher commented on Jul 3, 2023

    @brandtbucher
    brandtbucher
    on Jul 3, 2023
    MemberAuthor
    More actions

    Huh. Yeah, I'll take a look.

  7. brandtbucher
    reopened this on Jul 3, 2023
  8. brandtbucher commented on Jul 3, 2023

    @brandtbucher
    brandtbucher
    on Jul 3, 2023
    MemberAuthor
    More actions

    Ah, I think I found it.

  9. pablogsal
    added a commit that references this issue on Jul 4, 2023

    GH-106008: Fix refleak when peepholing `None` comparisons (#106367)

    e4ba71f
  10. brandtbucher
    closed this as completedon Jul 5, 2023
  11. carljm
    added a commit that references this issue on Jul 5, 2023

    Merge branch 'main' into modulelocals

    4c59e51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @brandtbucher
    brandtbucher

Labels

3.13only security fixesonly security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    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.