-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
refactor: Speed up function _serialize_dataframe
by 123% in PR #6044 (refactor-serialization
)
#6078
Merged
ogabrielluiz
merged 24 commits into
main
from
codeflash/optimize-pr6044-2025-02-03T12.09.54
Feb 3, 2025
Merged
refactor: Speed up function _serialize_dataframe
by 123% in PR #6044 (refactor-serialization
)
#6078
ogabrielluiz
merged 24 commits into
main
from
codeflash/optimize-pr6044-2025-02-03T12.09.54
Feb 3, 2025
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…d a unified serialize method
…ums, and generic types
… errors gracefully
…arious data types
…unction for consistency and maintainability
…lize method for improved clarity and maintainability
…unction for improved consistency and clarity
… streamlining type checks
…nse for streamlined handling
…tems_length for improved handling of outputs, logs, messages, and artifacts
…alization module for better organization
…ified serialize function
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
… unsupported types
…ad of its string representation
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
…actor-serialization`) Certainly! Here's a more efficient version of the given program. The primary optimization performed here is removing the redundant `.apply()` call and directly truncating values in a more performant way. ### Changes Made. 1. **Removed redundant `apply` calls**: In the original code, there were nested `apply` calls which can be very slow on larger DataFrames. The new implementation converts the DataFrame to a list of dictionaries first and then truncates the values if needed. 2. **Optimized truncation logic**: Applied truncation directly while iterating over the dictionary after conversion from a DataFrame. This reduces overhead and improves readability. These changes should enhance the runtime performance of the serialization process, especially for larger DataFrames.
ogabrielluiz
approved these changes
Feb 3, 2025
_serialize_dataframe
by 123% in PR #6044 (refactor-serialization
)_serialize_dataframe
by 123% in PR #6044 (refactor-serialization
)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
⚡️ codeflash
Optimization PR opened by Codeflash AI
enhancement
New feature or request
lgtm
This PR has been approved by a maintainer
size:XS
This PR changes 0-9 lines, ignoring generated files.
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.
⚡️ This pull request contains optimizations for PR #6044
If you approve this dependent PR, these changes will be merged into the original PR branch
refactor-serialization
.📄 123% (1.23x) speedup for
_serialize_dataframe
insrc/backend/base/langflow/serialization/serialization.py
⏱️ Runtime :
23.9 milliseconds
→10.7 milliseconds
(best of141
runs)📝 Explanation and details
Certainly! Here's a more efficient version of the given program. The primary optimization performed here is removing the redundant
.apply()
call and directly truncating values in a more performant way.Changes Made.
apply
calls: In the original code, there were nestedapply
calls which can be very slow on larger DataFrames. The new implementation converts the DataFrame to a list of dictionaries first and then truncates the values if needed.These changes should enhance the runtime performance of the serialization process, especially for larger DataFrames.
✅ Correctness verification report:
🌀 Generated Regression Tests Details