Skip to content

Conversation

@lysnikolaou
Copy link

Since the next version is going to be supporting the free-threaded build, I thought it might be nice to have a note about it in the README. If it's desirable, I can also update the docs.

@methane methane requested a review from Copilot November 29, 2025 13:56
Copilot finished reviewing on behalf of methane November 29, 2025 13:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds documentation to the README explaining thread safety guarantees for msgpack when used with CPython 3.14's free-threaded build (PEP 703). The documentation clarifies that Packer and Unpacker instances are thread-safe through critical section locking, and provides performance guidance on creating separate instances per thread for optimal performance.

Key changes:

  • Documents thread safety guarantees for Packer and Unpacker instances
  • Explains thread safety of module-level functions like packb() and unpackb()
  • Provides a code example demonstrating the recommended pattern for multi-threaded usage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return packer.pack(data)

with ThreadPoolExecutor(max_workers=4) as executor:
results = executor.map(worker, <data>)
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

The code example contains a syntax error with the placeholder <data>. This should be replaced with a concrete example like [1, 2, 3, 4] or data_items to make the example functional and executable.

Suggested change
results = executor.map(worker, <data>)
results = executor.map(worker, [1, 2, 3, 4])

Copilot uses AI. Check for mistakes.
it may serialize operations due to critical section locking. For optimal
performance in multi-threaded applications, create separate instances per thread:

```python
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

The code block uses python which is inconsistent with the existing README convention. Other non-interactive code examples in this README use py (see lines 60, 81). For consistency, this should be changed to ```py.

Suggested change
```python
```py

Copilot uses AI. Check for mistakes.
return packer.pack(data)

with ThreadPoolExecutor(max_workers=4) as executor:
results = executor.map(worker, <data>)
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

The new thread safety documentation and recommended usage pattern lacks test coverage. Consider adding a test case that validates thread-safe usage of Packer and Unpacker instances across multiple threads, similar to the example provided in the documentation.

Copilot uses AI. Check for mistakes.
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