-
Notifications
You must be signed in to change notification settings - Fork 61
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
add rdiv and friends (only radd is already implemented) #70
Comments
Although Starlark is designed mainly as a configuration language and not as an all-purpose scripting language, adding operations like rdiv would make it more consistent. |
Part of the problem is that |
We actually changed that after adding special cases for strings and numbers, so the overhead of looking up for (I don't see a benchmark on the diff, but I think I checked it is fine). To answer your question, vast majority of binops are |
thanks for looking into this so quickly, just a note, I recently read a bit about performance of dunder methods in python and opened an issue there faster-cpython/ideas#555 so that might be interesting for starlark as well |
Does this mean that this issue could be implemented? I'm not yet sure if its basically just a matter of copying some stuff in https://github.com/facebookexperimental/starlark-rust/blob/5febddfb306956ca11c88e2b75ac7acf631b1bac/starlark/src/values/traits.rs#L568-L589 and probably https://github.com/facebookexperimental/starlark-rust/blob/5febddfb306956ca11c88e2b75ac7acf631b1bac/starlark/src/values/layout/vtable.rs#L422-L429 or if there are more invasive changes needed? |
Yes. |
No. Starlark does not allow operator overloading in non-native code, so the problem does not exist in starlark-rust. Operator call is basically a simple virtual call (or two, in case of Also we use "slots" for builtin methods (like |
just for reference if someone comes around this: dc68400 which is probably a blueprint for the remaining ops |
careful with that as a blueprint. it looks like there's a bug in that it doesn't actually call rmul in the reverse case (it just calls mul). This bug appears to still exist in head (cc @stepancheg) |
@cjhopman fix in D49195881. |
Summary: CC facebook/starlark-rust#70 Reviewed By: cjhopman Differential Revision: D49195881 fbshipit-source-id: a64be482041e58a1c56d2ffdde80c540509e00fa
Summary: CC #70 Reviewed By: cjhopman Differential Revision: D49195881 fbshipit-source-id: a64be482041e58a1c56d2ffdde80c540509e00fa
like defined in https://docs.python.org/3.11/reference/datamodel.html#emulating-numeric-types
this is helpful for emulating/ creating apis like the python ones of z3 or sympy, using starlark as the scripting engine instead of python, writing the core logic in rust
The text was updated successfully, but these errors were encountered: