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

struct.pack format #1

Open
DamienCassou opened this issue Mar 1, 2019 · 2 comments
Open

struct.pack format #1

DamienCassou opened this issue Mar 1, 2019 · 2 comments

Comments

@DamienCassou
Copy link

Hi,

in the code of this project, one can read:

message_length = struct.unpack("@I", raw_length)[0]

In the MDN's documentation, one can read:

message_length = struct.unpack('=I', raw_length)[0]

Would you mind telling me why you chose to use "@I" for the format instead of "=I"?

The related Python documentation is at: https://docs.python.org/2/library/struct.html

@Rayquaza01
Copy link
Owner

Hello,
The ping_pong.py file from MDN's webextension examples repo uses "@I" instead of "=I", which is where I got that from. I can't remember specifically why I chose to use "@I", but both seem to work the same.

Here's the edit on MDN where @ is changed to =

[...]Either works as long native int is 32-bits (which I think is everywhere Firefox runs), but using @I is misleading.

And the Google Chrome sample host just uses I, no @ or =, which is the same as @I according to the Python docs.

So, I don't think it really matters unless there's a system that has a native size for ints that's different from the standard size.

@DamienCassou
Copy link
Author

DamienCassou commented Mar 3, 2019 via email

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

No branches or pull requests

2 participants