-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[python] FR: Drop table names prefixing generated methods #6309
Comments
Hmm, not a Python user so hard to say how common this Opinions @rw @lu-wang-g ? |
@rhofour This sounds like a good idea. I particularly like your suggestion that this could make it easier for users to operate on generated code. This seems part of a bigger goal of ours: make the generated Python code more idiomatic. |
Yeah, I agree this will make the generated code a lot concise, and it's also aligned with Google's Python Code Style recommendation. I main concern is the API incompatibility issue. As @aardappel said, we could start with a flag, and then fully upgrade to the "simpler version" in the next major version release, such as Flatbuffers v12. |
Sounds good, I'll start work on a PR. |
I've seen several mentions of a new release coming soon, should I still stick with a flag or can I just make this a breaking change? |
@rw do you feel this is worth a breaking change? |
I can modify my PR to make it slightly less breaking by making all the old names point to the new ones. I think it would still break for people who use "import *", but that's smaller than the current change. That said, I (obviously) personally feel like these new names are much more idiomatic and are worth the change. Making the changes in the tutorial was actually not too bad. It's a lot of lines changed, but with a few regexps it's pretty easy. |
I'd like this to not break anyone's code for now; e.g. TFLite relies on the current naming: #6336 (comment) |
I think this should be included in the 2.0 tracking: #6353 |
So, are we making any non-breaking changes related to this before 2.0, or can we close this / leave it till after 2.0? |
The PR I have out should be minimally breaking. All the old method names are there with a deprecated comment so only people using I can check if it needs to be updated to safely merge later tonight. |
Closing, since the related PR was merged. |
Right now the generated Python methods feel excessively verbose. All of the methods for building a table are prefixed with the table's name (ex:
MyGame.Sample.Weapon.WeaponStart(builder)
).I see how this is necessary if these were intended to be imported directly (
from MyGame.Sample.Weapon import *
), but this is considered poor practice and isn't what the tutorial shows. If these methods simply dropped the prefix thenMyGame.Sample.Weapon.WeaponStart
would become the shorter, but completely unambiguousMyGame.Sample.Weapon.Start
.Would there be any interest in a PR doing this? Shorter variants could be added that simply point to the existing methods to avoid breaking backwards compatibility (though this would still lead to conflicts for people who use import *).
Another minor advantage is this would allow Python code that could do things like generically start any table. I don't have use for this, but maybe someone else will.
The text was updated successfully, but these errors were encountered: