Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py/modio.c: Add SEEK_SET, SEEK_CUR and SEEK_END to io module. #3383

Closed
wants to merge 1 commit into from

Conversation

Li-Weiwei
Copy link
Contributor

You can now use SEEK_SET, SEEK_CUR and SEEK_END instead of 0, 1 and 2 in
the whence parameter of the seek function.

You can now use SEEK_SET, SEEK_CUR and SEEK_END instead of 0, 1 and 2 in
the whence parameter of the seek function.
Copy link
Contributor

@pfalcon pfalcon left a comment

Choose a reason for hiding this comment

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

You can now use SEEK_SET, SEEK_CUR and SEEK_END instead of 0, 1 and 2 in

No, vice-versa, you can you use 0, 1 and 2 instead of SEEK_SET, SEEK_CUR and SEEK_END. Or if you insist on using them, you can define them in your python code - all that without incurring overhead on people who don't use those constants.

@Li-Weiwei
Copy link
Contributor Author

This makes the seek function more intuitive, just as SOCK_STREAM and SOCK_DGRAM are in the sock class.

@Li-Weiwei
Copy link
Contributor Author

Well, that doesn't seem necessary. @pfalcon Thank you for your review.

@Li-Weiwei Li-Weiwei closed this Oct 21, 2017
@pfalcon
Copy link
Contributor

pfalcon commented Oct 21, 2017

It's true that it's more intuitive, but we also should maintain balance with code size required. As https://github.com/micropython/micropython/wiki/ContributorGuidelines suggestion, if something can be done in Python, it better be done in Python. It would be nice to drop SOCK_STREAM and SOCK_DGRAM too, but numbers behind them aren't well known and mostly consistent across systems, unlike SEEK_* constants.

Anyway, I added those to micropython/micropython-lib@7231559 (I was surprised they weren't there after 3 years - shows that people get around them pretty well).

@robert-hh
Copy link
Contributor

Thanks, Paul. For me that looks like a good way dealing with Li-Weiwei's suggestion, especially since the library is meant to be the place for extensions.

@Li-Weiwei
Copy link
Contributor Author

I have not been concerned about micropython-lib before. I used to wonder why micropython and CPython are inconsistent on some conventional parameters.
It's really best to weigh these constants into micropython-lib to balance the code size. Thanks.

tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Jun 23, 2021
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Jun 23, 2021
Fix for issue micropython#3383 - SAMD5x microcontroller.cpu.voltage
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.

None yet

3 participants