Thanks to visit codestin.com
Credit goes to github.com

Skip to content

perf: Use flyweight for node fields #1654

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

Merged
merged 3 commits into from
Apr 24, 2025
Merged

perf: Use flyweight for node fields #1654

merged 3 commits into from
Apr 24, 2025

Conversation

TrevorBergeron
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Apr 23, 2025
@TrevorBergeron TrevorBergeron requested a review from sycai April 23, 2025 23:38
@TrevorBergeron TrevorBergeron marked this pull request as ready for review April 23, 2025 23:38
@TrevorBergeron TrevorBergeron requested review from a team as code owners April 23, 2025 23:38
@@ -0,0 +1,53 @@
# Copyright 2024 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 2025

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

# * Support insertions and deletions


class ChainList(collections.abc.Sequence[T]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add some more doc to describe what this classes does. It's not obvious that the goal is to quickly locate an element from a concatenated sequence.

Plus, perhaps "ChainedSequence" is a better name?

In addition, this implementation might hurt performance if the provided "parts" are all very short. In that case, we are effectively using iterations in getitem(). Does it make sense to have certain kind of threshold? That is, if the total number of element is below certain threshold (10 maybe?), just concat everything into a tuple. Otherwise, use the current technique.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added docstring and renamed

Added some conservative compaction logic as well. Key here is memory efficiency/reuse rather than lookup efficiency, so don't want to go to wild on those types of optimizations.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 24, 2025
@TrevorBergeron TrevorBergeron requested a review from sycai April 24, 2025 20:02
@TrevorBergeron TrevorBergeron merged commit 8482bfc into main Apr 24, 2025
24 checks passed
@TrevorBergeron TrevorBergeron deleted the fly_fields branch April 24, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants