bt2: use `_extract_value()` on comparison
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 27 Jun 2019 23:38:59 +0000 (19:38 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:33 +0000 (11:53 -0400)
commit5f953519a108fd1028fcab6cbd1ec6e8ef371b22
tree766f66323b3cf59af82a46a72d870c7ec7e7fa74
parent9eb7fb56de07bb319dfd6f971fbcc4db45736f70
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.024393 seconds and 4 git commands to generate.