bt2: use `_extract_value()` on comparison
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 27 Jun 2019 23:38:59 +0000 (19:38 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jun 2019 02:47:25 +0000 (22:47 -0400)
commit09a926c19afa6e137319da5f9fd60b0852946ea4
tree4c1a33c00b4a7b051afb4329aeac354663dd50ca
parent7bb4180f2758d78af3f4d539f6b3e4e1fa60335f
bt2: use `_extract_value()` on comparison

After further discussions, we realized that there was a better way to
address the issue that commit 7bb4180 is fixing.

The real issue was that we were unconditionally converting the `other`
object to the `complex` type even when neither objects were of the
`complex` type. This was causing problem because of the lost of
precision when storing very large integer value in a variable of
`complex` type.

The better solution is to convert both objects to the type of the wider
object, and that is what Python does automatically. To enable that, we
simply need to convert the `other` object to it's corresponding standard
numeric type [1]. This commit uses the existing `_extract_value()`
method to achieve that.

[1]: https://docs.python.org/3/library/stdtypes.html#numeric-types-int-float-complex

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib658d1fdaf41a0ee592212a101fa4ad0ea952eb4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1561
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/bindings/python/bt2/bt2/field.py
src/bindings/python/bt2/bt2/value.py
This page took 0.02484 seconds and 4 git commands to generate.