-
Notifications
You must be signed in to change notification settings - Fork 54
Remove redudant numpy.array()
#232
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
Conversation
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with green CI.
Pulls: #232 |
should we backport this ? @InvincibleRMC or @fujitatomoya |
@Mergifyio backport kilted jazzy humble |
✅ Backports have been created
|
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com> (cherry picked from commit 5e206b3) # Conflicts: # rosidl_generator_py/resource/_msg.py.em
i think there is no downside to backport this, @InvincibleRMC correct me if i am wrong on that? |
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com> (cherry picked from commit 5e206b3) # Conflicts: # rosidl_generator_py/resource/_msg.py.em
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com> (cherry picked from commit 5e206b3) # Conflicts: # rosidl_generator_py/resource/_msg.py.em
Yeah should be fine. |
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com>
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com> (cherry picked from commit 9848f85)
Signed-off-by: Michael Carlstrom <rmc@carlstrom.com> (cherry picked from commit 9848f85)
Description
When constructing a msg for a field that is stored in a
numpy
array it calls thenumpy.array()
in the constructor and then again inside the property setter. This only seems to be the case for these arrays for whatever reason. Forarray.array
backed field for example it does the conversion within the setter property. For the message I tested where I set all 11numpy
array back fields it resulted in a 15-20% speed improvement on construction.Methodology
Collected data
100,000 Instantiates repeated 100 times
No duplicate np.array call
median: 1.7657687720002286, mean: 1.7685977168901081, mode: 1.8006701040012558
Duplicated np.array call
median: 2.1092314300003636, mean: 2.110108332149866, mode: 2.1043354339999496
1 Instantiates repeated 1,000,000 times
No duplicate np.array call
median: 1.8749997252598405e-05, mean: 1.866378419397697e-05, mode: 1.8961000023409724e-05
Duplicated np.array call
median: 2.242299888166599e-05, mean: 2.229084920763089e-05, mode: 2.2606000129599124e-05
Is this user-facing behavior change?
Did you use Generative AI?
Additional Information