Skip to content

Conversation

@rodrigobnogueira
Copy link

@rodrigobnogueira rodrigobnogueira commented Dec 26, 2025

Description

Added a comprehensive implementation of the endianness (byte order) conversion algorithm in Python. The implementation includes byte order swapping for 16/32/64-bit integers and bidirectional bytes ↔ integer conversions for both big-endian and little-endian formats.

Features

  • Byte order swapping: swap_endianness_16(), swap_endianness_32(), swap_endianness_64()
  • Bytes to integer conversions: bytes_to_int_little(), bytes_to_int_big()
  • Integer to bytes conversions: int_to_bytes_little(), int_to_bytes_big()
  • Comprehensive documentation with real-world use cases
  • Full doctest coverage with type hints

Use Cases

The implementation documents practical real-world applications:

  • Network protocols (TCP/IP uses big-endian/network byte order)
  • Cryptographic algorithms (MD5 uses little-endian, SHA-256 uses big-endian)
  • File format parsing (PNG, JPEG headers)
  • Binary data serialization (Protocol Buffers, MessagePack)
  • Hardware interfacing and cross-platform data exchange

References

Checklist

  • I have read and followed the contributing guidelines
  • This pull request is not a duplicate
  • The algorithm is implemented from scratch
  • The code follows the repository style
  • I have read CONTRIBUTING.md
  • This pull request is all my own work -- I have not plagiarized
  • I know that pull requests will not be merged if they fail the automated tests
  • This PR only changes one algorithm file
  • All new Python files are placed inside an existing directory (conversions/)
  • All filenames are in all lowercase characters with no spaces or dashes
  • All functions and variable names follow Python naming conventions
  • All function parameters and return values are annotated with Python type hints
  • All functions have doctests that pass the automated testing
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation

rodrigo.nogueira added 2 commits December 25, 2025 15:34
- Implement xxHash32 with 4-accumulator parallel processing
- Add 15 comprehensive doctests with seed support
- Full type hints and English documentation
- Passes ruff and mypy checks

xxHash is extremely fast and used in Zstandard, LZ4, and rsync.
Features optimized processing with carefully selected prime constants.
- Implements byte order conversions for 16/32/64-bit integers
- Provides bidirectional bytes ↔ int conversions
- Supports both big-endian and little-endian formats
- Includes comprehensive doctests with real-world examples
- Documents use cases: network protocols, cryptography, file formats
- All tests pass: ruff, mypy, doctests
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