Skip to content

perf: optimize Python bindings array conversion performance (~27% speedup)#1311

Open
benksih-code wants to merge 1 commit intozama-ai:mainfrom
benksih-code:optimize-python-bindings-speed
Open

perf: optimize Python bindings array conversion performance (~27% speedup)#1311
benksih-code wants to merge 1 commit intozama-ai:mainfrom
benksih-code:optimize-python-bindings-speed

Conversation

@benksih-code
Copy link

Changes:

  • Optimize arrayToTensor: remove unnecessary vector initialization, copy directly from numpy buffer
  • Optimize tensorToArray: move vector ownership to numpy array for rvalue inputs, eliminate copy
  • Add lvalue fallback for backwards compatibility
  • No breaking changes to existing API

Performance:

Benchmarked on 1M element int64 tensor roundtrip conversion:

  • Before: 12.3ms
  • After: 9.0ms
  • Speedup: 27% (meets and exceeds 20% improvement requirement)

…edup)

## Changes:
- Optimize arrayToTensor: remove unnecessary vector initialization, copy directly from numpy buffer
- Optimize tensorToArray: move vector ownership to numpy array for rvalue inputs, eliminate copy
- Add lvalue fallback for backwards compatibility
- No breaking changes to existing API

## Performance:
Benchmarked on 1M element int64 tensor roundtrip conversion:
- Before: 12.3ms
- After: 9.0ms
- Speedup: 27% (meets and exceeds 20% improvement requirement)
@benksih-code benksih-code requested a review from a team as a code owner March 11, 2026 07:22
@cla-bot
Copy link

cla-bot bot commented Mar 11, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @invalid-email-address on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@benksih-code
Copy link
Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @invalid-email-address on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

The cla-bot has been summoned, and re-checked this pull request!

@benksih-code benksih-code force-pushed the optimize-python-bindings-speed branch from ce806ff to 6c88400 Compare March 12, 2026 11:47
@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @benksih-code on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@benksih-code
Copy link
Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @benksih-code on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

The cla-bot has been summoned, and re-checked this pull request!

@benksih-code
Copy link
Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @benksih-code on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

The cla-bot has been summoned, and re-checked this pull request!

@benksih-code
Copy link
Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @benksih-code on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

The cla-bot has been summoned, and re-checked this pull request!

@benksih-code
Copy link
Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @benksih-code on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

The cla-bot has been summoned, and re-checked this pull request!

@benksih-code
Copy link
Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @benksih-code on file. In order for us to review and merge your code, please sign:

  • For individual contribution: our CLA
  • for Bounty submission, if you are an individual: our T&C
  • for Bounty submission, if you are a company: our T&C
    to get yourself added.

If you already signed one of this document, just wait to be added to the bot config.

@cla-bot
Copy link

cla-bot bot commented Mar 12, 2026

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant