Title: Expose top-level pack/unpack helpers from the Rust extension by Copilot · Pull Request #1 · methane/msgpack-python · GitHub
Open Graph Title: Expose top-level pack/unpack helpers from the Rust extension by Copilot · Pull Request #1 · methane/msgpack-python
X Title: Expose top-level pack/unpack helpers from the Rust extension by Copilot · Pull Request #1 · methane/msgpack-python
Description: The Rust _cmsgpack module still routed top-level helper behavior through Python-side wrappers, so the fast path stopped at the class boundary. This change makes the module provide the public helper surface directly, so msgpack.pack* / msgpack.unpack* use the extension implementation when available. Rust module API Added module-level pack, packb, unpack, and unpackb to /tmp/workspace/methane/msgpack-python/src/lib.rs Kept behavior aligned with existing Python semantics, including stream handling and unpackb error translation Top-level binding Updated /tmp/workspace/methane/msgpack-python/msgpack/__init__.py to import the helper functions from _cmsgpack when the extension is active Preserved the existing pure-Python fallback path unchanged when MSGPACK_PUREPYTHON is set or the extension is unavailable Coverage Extended /tmp/workspace/methane/msgpack-python/test/test_rust_backend.py to verify the extension exports the helper functions and that the top-level API resolves to them in extension mode Example: import io import msgpack buf = io.BytesIO() msgpack.pack({"value": 1}, buf) # uses Rust helper when _cmsgpack is available payload = msgpack.packb([1, 2, 3]) obj = msgpack.unpackb(payload) Original prompt methane/msgpack-python リポジトリに対して、Cythonで実装されている部分をRustで再実装し、可能な限り既存のPython向け公開API・挙動・テスト互換性を維持してください。 目的: リポジトリ内のCython由来の拡張実装(例: .pyx, .pxd, cythonize 対象、Cythonベースの高速化コード)を特定する。 それらをRustで置き換える。 Python から利用可能な拡張モジュールとしてビルドできるようにする。 既存テストが通るように調整する。 要件: まず現在のCython実装の範囲と、Python公開APIとの対応を調査する。 Rust実装にはPythonバインディングを用いること。リポジトリの既存構成に適した方法(たとえば PyO3 / maturin / setuptools-rust 等)を選定する。 既存の配布・ビルド構成(pyproject.toml, setup.py, setup.cfg, CI など)があれば、それに整合するよう最小限の変更で統合する。 既存の挙動・例外・シリアライズ/デシリアライズ結果・性能上重要な経路について、できるだけ互換性を保つ。 Cythonコードが複数箇所に分かれている場合は、すべてRustに移行する。ただし、互換性やビルド上の制約で完全移行が難しい箇所がある場合は、PR説明に未移行箇所・理由・次のステップを明記する。 必要に応じてテストやベンチ、ドキュメント、ビルド設定を更新する。 実装後、変更内容・移行方針・既知の制約をPR本文に明記する。 期待成果: Rustベースの実装 必要なビルド設定変更 テスト更新 PR作成 PRタイトルは、CythonからRustへの移行であることが分かる簡潔なものにしてください。 The following is the prior conversation context from the user's chat exploration (may be truncated): User: Cythonで書かれている部分を全部Rustで再実装してみて。 Assistant: 対象のリポジトリがまだ分からないので、先にそれだけ教えてください。 必要なのは少なくともこれです。 GitHub リポジトリ: owner/repo 形式 可能なら 対象ブランチ 「全部」の範囲確認: Cython の .pyx / .pxd / cythonize 対象をすべてRust化するのか まずは一部を段階的に置き換えるのか 期待する成果物: PRを作る ところまでやる まずは 調査して移行計画を出す だけにする もしそのまま実装まで進めたいなら、例えばこう指定してください。 owner/repo: your-org/your-repo branch: main やること: Cython実装をRustへ全面移行、Pythonバインディングも維持 成果物: PR作成まで リポジトリが分かれば、こちらでコードを調べて Cython 部分を洗い出し、Rust 実装方針をまとめたうえで進めます。 User: methane/msgpack-python Assistant: 承認待ちです。確認ダイアログで許可してもらえれば、そのまま実装とPR作成に進めます。 This pull request was created from Copilot chat.
Open Graph Description: The Rust _cmsgpack module still routed top-level helper behavior through Python-side wrappers, so the fast path stopped at the class boundary. This change makes the module provide the public helper...
X Description: The Rust _cmsgpack module still routed top-level helper behavior through Python-side wrappers, so the fast path stopped at the class boundary. This change makes the module provide the public helper...
Opengraph URL: https://github.com/methane/msgpack-python/pull/1
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:cdb971ff-13eb-4dd0-3634-c54834b26bc6 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D55C:3D7639:E3B452:149FA8F:6A4E5008 |
| html-safe-nonce | f0d3e1d885bd60956149a47a9d3713ee3e81b65769bc6cb76e8edfa5aec1ddf5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTVDOjNENzYzOTpFM0I0NTI6MTQ5RkE4Rjo2QTRFNTAwOCIsInZpc2l0b3JfaWQiOiI1ODY4MzU0NDg3MDc3MTk1Nzg0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ec47cb23da7743fe133adb821555e725eccaf65eececc3528f9dcb3b432e0bcd |
| hovercard-subject-tag | pull_request:3766584517 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/methane/msgpack-python/pull/1/files |
| twitter:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/in/1143301?s=400&v=4 |
| og:image:alt | The Rust _cmsgpack module still routed top-level helper behavior through Python-side wrappers, so the fast path stopped at the class boundary. This change makes the module provide the public helper... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/methane/msgpack-python git https://github.com/methane/msgpack-python.git |
| octolytics-dimension-user_id | 199592 |
| octolytics-dimension-user_login | methane |
| octolytics-dimension-repository_id | 1253023006 |
| octolytics-dimension-repository_nwo | methane/msgpack-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 2242705 |
| octolytics-dimension-repository_parent_nwo | msgpack/msgpack-python |
| octolytics-dimension-repository_network_root_id | 2242705 |
| octolytics-dimension-repository_network_root_nwo | msgpack/msgpack-python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f344f1eab54fc7dfc02d0d018cda7e158c3db65c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width