Title: Fold const bool with unary not by moreal · Pull Request #7357 · RustPython/RustPython · GitHub
Open Graph Title: Fold const bool with unary not by moreal · Pull Request #7357 · RustPython/RustPython
X Title: Fold const bool with unary not by moreal · Pull Request #7357 · RustPython/RustPython
Description: This pull request includes two optimizations: Merges consecutive LOAD_CONST True (or False) and UNARY_NOT into one. Omits TO_BOOL when it follows LOAD_CONST True, as it's redundant. While the former might not be a common scenario, I believe the latter will be quite useful. For x = not True, previously, it was compiled into the following lines: 1 0 RESUME (0) 1 LOAD_CONST (True) 2 TO_BOOL 3 CACHE 4 CACHE 5 CACHE 6 UNARY_NOT 7 STORE_NAME (0, x) 8 LOAD_CONST (None) 9 RETURN_VALUE After this pull request, it will be compiled like the following lines: 1 0 RESUME (0) 1 LOAD_CONST (False) 2 STORE_NAME (0, x) 3 LOAD_CONST (None) 4 RETURN_VALUE Summary by CodeRabbit Optimization Enhanced compiler optimization for boolean operations through improved constant-folding, simplifying boolean expressions into more efficient instruction sequences. Tests Added test coverage for boolean constant handling and boolean negation operations to validate compiler behavior with optimized compilation settings.
Open Graph Description: This pull request includes two optimizations: Merges consecutive LOAD_CONST True (or False) and UNARY_NOT into one. Omits TO_BOOL when it follows LOAD_CONST True, as it's redundant. While the...
X Description: This pull request includes two optimizations: Merges consecutive LOAD_CONST True (or False) and UNARY_NOT into one. Omits TO_BOOL when it follows LOAD_CONST True, as it's redundant. While...
Opengraph URL: https://github.com/RustPython/RustPython/pull/7357
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:aafdcbed-2d34-30f7-6f72-8f4f32cb8174 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E3C6:92C50:F1787:153FE4:6A604F7B |
| html-safe-nonce | 704b214ab5015fee61e0f548f907a3e488d76b8b4a2f02bcbb575872d6c292f8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0M2OjkyQzUwOkYxNzg3OjE1M0ZFNDo2QTYwNEY3QiIsInZpc2l0b3JfaWQiOiI2NTUxODc2NDMwMzM1MDcwMDc1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 7a8abfee664779ea30faabc3eda5dbffc02d014e67b93376c5513ecd47bfb976 |
| hovercard-subject-tag | pull_request:3357074300 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/7357/files |
| twitter:image | https://avatars.githubusercontent.com/u/26626194?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26626194?s=400&v=4 |
| og:image:alt | This pull request includes two optimizations: Merges consecutive LOAD_CONST True (or False) and UNARY_NOT into one. Omits TO_BOOL when it follows LOAD_CONST True, as it's redundant. While the... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60da8c2a42fa2bbf5f7567474990ec467836a84444262a58e200fa91b7f3d2d0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9824515e740d83d5eb82168a089b806ab0fe04a1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width