QoL improvements for data stream handling#74
Merged
leif81 merged 2 commits intoopen-dis:masterfrom Sep 23, 2025
Merged
Conversation
Member
|
Thank-you @ngjunsiang |
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.
Proposal
Improve quality-of-life (QoL) by adding convenience methods to data-handling classes, and centralise them under a
streammodule.Rationale
The interface for
DataInputStreamandDataOutputStreamare inspired by the classes of the same name from Java (see https://docs.oracle.com/javase/8/docs/api/java/io/DataOutputStream.html). Java programmers would no doubt be more familiar with those method names and their uses.However, their use in a Python package is less helpful, as Python generally does not use these names. Furthermore, IEEE1278.1-2012 also does not use those names, instead using 16-bit signed integer, 8-bit unsigned integer, etc.
Furthermore, a number of issues & PRs can be traced to use of the wrong method:
These bugs can be more easily avoided with names that align with the IEEE1278.1-2012 documentation, and with the type names that already exist in the
typesmodule.Changes
This PR proposes a couple of QoL improvements to make bugs easier to catch and fix, and to lay the ground for further work on type validation. The changes in this PR do not break any existing code.
read_int8(), ...read_uint8(), ..., and thewrite_*equivalents) to theDataInputStreamandDataOutputStreamclasses. These methods are aliases that call the appropriate read/write method.streammodule from which to import theDataInputStreamandDataOutputStreamclasses. Unlike in Java, Python does not have a convention of requiring classes to be in separate file. Furthermore, Python prefers lowercase module names. This naming aligns better with PEP8 and other Python conventions expected by Python programmers.Future work (beyond this PR)
If this PR is approved, future work may include:
DataInputStream.pyandDataOutputStream.pyunderstreamaltogether, simplifying the directory structure