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 — build: use list for mutable retval rather than tuple by Trott · Pull Request #41372 · nodejs/node

Conversation

@Trott

@Trott Trott commented Jan 1, 2022

Copy link
Copy Markdown
Member

This is a really small semantic Python nit. Pinging @nodejs/python in case I'm just wrong in my understanding or something.

We define retval as a tuple and then replace the tuple by "appending" items with += but that actually creates a new tuple every time. Because it is intended to be mutable, use a list instead, then return a tuple from the function, as it should be immutable outside the function.

Sorry, something went wrong.

Uh oh!

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

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@Trott
build: use list for mutable retval rather than tuple
68cc26e
We define `retval` as a tuple and then replace the tuple by "appending"
items with `+=` but that actually creates a new tuple every time.
Because it is intended to be mutable, use a list instead, then return a
tuple from the function, as it should be immutable outside the function.
@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to Node.js builds or CI infrastructure. needs-ci PRs that need a full CI run. labels Jan 1, 2022
@Trott Trott added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. and removed build Issues and PRs related to Node.js builds or CI infrastructure. needs-ci PRs that need a full CI run. labels Jan 1, 2022
Mesteery
Mesteery reviewed Jan 1, 2022
View reviewed changes
Comment thread configure.py Resolved

Uh oh!

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

@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Jan 1, 2022
@nodejs-github-bot

This comment has been minimized.

Sign in to view
@Trott @Mesteery
Update configure.py
277dc43
Co-authored-by: Mestery <[email protected]>
@nodejs-github-bot

nodejs-github-bot commented Jan 1, 2022

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/41718/

All reactions

Sorry, something went wrong.

Uh oh!

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

@Mesteery Mesteery added the python PRs and issues that require attention from people who are familiar with Python. label Jan 1, 2022
cclauss
cclauss approved these changes Jan 1, 2022
View reviewed changes

@cclauss cclauss left a comment •
edited
Loading

Uh oh!

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

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.

Approve. Under heavy use, the proposed syntax is a nice performance boost...
% py -3.10 # 100k cycles on an M1 Mac...

Python 3.10.1 (main, Dec  6 2021, 22:18:13) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from timeit import timeit
>>> print(timeit("abc += ['d']", "abc = list('abc')", number=100_000))
0.011850042035803199
>>> print(timeit("abc.append('d')", "abc = list('abc')", number=100_000))
0.010260708979330957
>>> print(timeit("abc += ('d', )", "abc = tuple('abc')", number=100_000))
20.874202583101578

Sorry, something went wrong.

Uh oh!

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

All reactions
@Trott Trott added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jan 1, 2022
tniessen
tniessen reviewed Jan 1, 2022
View reviewed changes
Comment thread configure.py Resolved

Uh oh!

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

tniessen
tniessen approved these changes Jan 2, 2022
View reviewed changes
@Trott Trott added the commit-queue PRs queued for automated landing through the Commit Queue. label Jan 5, 2022
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Jan 5, 2022
@nodejs-github-bot

nodejs-github-bot commented Jan 5, 2022

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/41372
✔  Done loading data for nodejs/node/pull/41372
----------------------------------- PR info ------------------------------------
Title      build: use list for mutable retval rather than tuple (#41372)
Author     Rich Trott  (@Trott)
Branch     Trott:python-nit -> nodejs:master
Labels     python, author ready
Commits    2
 - build: use list for mutable retval rather than tuple
 - Update configure.py
Committers 2
 - Rich Trott 
 - GitHub 
PR-URL: https://github.com/nodejs/node/pull/41372
Reviewed-By: Christian Clauss 
Reviewed-By: Tobias Nießen 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/41372
Reviewed-By: Christian Clauss 
Reviewed-By: Tobias Nießen 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Sat, 01 Jan 2022 17:10:54 GMT
   ✔  Approvals: 2
   ✔  - Christian Clauss (@cclauss): https://github.com/nodejs/node/pull/41372#pullrequestreview-842349446
   ✔  - Tobias Nießen (@tniessen) (TSC): https://github.com/nodejs/node/pull/41372#pullrequestreview-842435129
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-01-01T17:24:05Z: https://ci.nodejs.org/job/node-test-pull-request/41718/
- Querying data for job/node-test-pull-request/41718/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/master up to date...
From https://github.com/nodejs/node
 * branch                  master     -> FETCH_HEAD
✔  origin/master is now up-to-date
- Downloading patch for 41372
From https://github.com/nodejs/node
 * branch                  refs/pull/41372/merge -> FETCH_HEAD
✔  Fetched commits as 513e9fd0b611..277dc43511ca
--------------------------------------------------------------------------------
[master 30b065eb28] build: use list for mutable retval rather than tuple
 Author: Rich Trott 
 Date: Sat Jan 1 09:05:03 2022 -0800
 1 file changed, 3 insertions(+), 3 deletions(-)
[master 2f121192c8] Update configure.py
 Author: Rich Trott 
 Date: Sat Jan 1 09:23:34 2022 -0800
 1 file changed, 1 insertion(+), 1 deletion(-)
   ✔  Patches applied
There are 2 commits in the PR. Attempting autorebase.
Rebasing (2/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
build: use list for mutable retval rather than tuple

We define retval as a tuple and then replace the tuple by "appending"
items with += but that actually creates a new tuple every time.
Because it is intended to be mutable, use a list instead, then return a
tuple from the function, as it should be immutable outside the function.

PR-URL: #41372
Reviewed-By: Christian Clauss [email protected]
Reviewed-By: Tobias Nießen [email protected]

[detached HEAD 1fd4e0a6a4] build: use list for mutable retval rather than tuple
Author: Rich Trott [email protected]
Date: Sat Jan 1 09:05:03 2022 -0800
1 file changed, 3 insertions(+), 3 deletions(-)
Rebasing (3/4)
Rebasing (4/4)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
Update configure.py

Co-authored-by: Mestery [email protected]

PR-URL: #41372
Reviewed-By: Christian Clauss [email protected]
Reviewed-By: Tobias Nießen [email protected]

[detached HEAD c7dc8f9f76] Update configure.py
Author: Rich Trott [email protected]
Date: Sat Jan 1 09:23:34 2022 -0800
1 file changed, 1 insertion(+), 1 deletion(-)

Successfully rebased and updated refs/heads/master.

ℹ Use --fixupAll option, squash the PR manually or land the PR from the command line.

https://github.com/nodejs/node/actions/runs/1656698573

All reactions

Sorry, something went wrong.

Uh oh!

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

@Trott Trott added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Jan 5, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Jan 5, 2022
@nodejs-github-bot
nodejs-github-bot merged commit bd92726 into nodejs:master Jan 5, 2022
@nodejs-github-bot

nodejs-github-bot commented Jan 5, 2022

Copy link
Copy Markdown
Collaborator

Landed in bd92726

All reactions

Sorry, something went wrong.

Uh oh!

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

targos pushed a commit that referenced this pull request Jan 14, 2022
@Trott @targos
build: use list for mutable retval rather than tuple
80a3766
We define `retval` as a tuple and then replace the tuple by "appending"
items with `+=` but that actually creates a new tuple every time.
Because it is intended to be mutable, use a list instead, then return a
tuple from the function, as it should be immutable outside the function.

PR-URL: #41372
Reviewed-By: Christian Clauss <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@targos targos mentioned this pull request Jan 16, 2022
v17.4.0 release proposal #41557
Merged
danielleadams pushed a commit that referenced this pull request Jan 31, 2022
@Trott @danielleadams
build: use list for mutable retval rather than tuple
1b438f0
We define `retval` as a tuple and then replace the tuple by "appending"
items with `+=` but that actually creates a new tuple every time.
Because it is intended to be mutable, use a list instead, then return a
tuple from the function, as it should be immutable outside the function.

PR-URL: #41372
Reviewed-By: Christian Clauss <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
danielleadams pushed a commit that referenced this pull request Feb 1, 2022
@Trott @danielleadams
build: use list for mutable retval rather than tuple
c65ac72
We define `retval` as a tuple and then replace the tuple by "appending"
items with `+=` but that actually creates a new tuple every time.
Because it is intended to be mutable, use a list instead, then return a
tuple from the function, as it should be immutable outside the function.

PR-URL: #41372
Reviewed-By: Christian Clauss <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@danielleadams danielleadams mentioned this pull request Feb 1, 2022
v16.14.0 proposal #41804
Merged
@Trott
Trott deleted the python-nit branch September 25, 2022 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cclauss cclauss cclauss approved these changes
@tniessen tniessen tniessen approved these changes
+1 more reviewer
@Mesteery Mesteery Mesteery 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

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-squash PRs the Commit Queue should land as one squashed commit. python PRs and issues that require attention from people who are familiar with Python.

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.

5 participants

@Trott @nodejs-github-bot @tniessen @cclauss @Mesteery
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.