fix: optimize base64 decoding and reduce string allocations in ConnectorRest - #712
Merged
Conversation
…torRest Fixes #232 by: - using pybase64 for faster decoding operations - utilizing response.json() instead of json.loads(response.text) to reduce redundant string parsing
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce client-side CPU usage for REST queries by optimizing how REST responses are parsed and how blobs are base64-decoded in ConnectorRest.
Changes:
- Add
pybase64as a dependency and prefer it for base64 decoding (with stdlib fallback). - Replace
json.loads(response.text)withresponse.json()to reduce intermediate string allocations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pyproject.toml | Adds pybase64 to project dependencies. |
| aperturedb/ConnectorRest.py | Prefers pybase64 for decoding and switches REST response parsing to response.json(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
luisremis
approved these changes
May 22, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR optimizes base64 decoding for REST connectors, which improves CPU utilization in client side during stress tests.
Fixes
Fixes #232
Verification
pybase64reduces base64 decoding time significantly (about 50% CPU savings locally compared to Python's built-inbase64.b64decode).json.loads(response.text)toresponse.json()which leverages Requests' optimized paths and reduces string overhead.ConnectorRest.pymodule and no syntax errors are introduced.