-
Kirill Smelkov authored
On Python two different objects with different types can represent essentially the same entity. For example 1 (int) and 1L (long) represent integer number one via two different types and are decoded by ogórek into Go types int64 and big.Int correspondingly. However on the Python side those two representations are often used interchangeably and programs are usually expected to handle both with the same effect. For example I hit this situation for real with FileStorage index, ZEO protocol, BTrees and Wendelin.core where data with integer fields, for the same field, are sometimes represented as int and sometimes as long. As the result ZODB/go and Wendelin.core had private XInt64 helper used as follows: https://lab.nexedi.com/nexedi/wendelin.core/-/blob/07087ec8/wcfs/internal/pycompat/pycompat.go https://lab.nexedi.com/nexedi/wendelin.core/-/blob/07087ec8/wcfs/internal/zdata/zblk.go#L385 https://lab.nexedi.com/search?utf8=%E2%9C%93&search=XInt64&group_id=&project_id=73&search_code=true&repository_ref=f7776fc1&nav_source=navbar Besides int/long we are also hitting similar situation with bytes / str(py2) / str(py3) which will also need to use corresponding helpers to be able to load pickled data from existing databases. In the next patch we will add StrictUnicode mode to handle that strings, and it will naturally come with AsBytes and AsString helpers. Thus it also feels appropriate to keep the other useful helpers to handle unpickled data inside ogórek itself. This patch adds AsInt64 helper with top-level description and tests.
010fbd2e