paleolimbot opened a new pull request, #425:
URL: https://github.com/apache/arrow-nanoarrow/pull/425

   I experimented with a few different methods here...I think this one has a 
good balance of speed and not messing with the global precision.
   
   ```python
   import pyarrow as pa
   import decimal
   from nanoarrow.iterator import iter_py
   
   items = [decimal.Decimal("12.3450"), None, decimal.Decimal("1234567.3456")]
   array = pa.array(items, pa.decimal128(11, 4))
   list(iter_py(array))
   #> [Decimal('12.3450'), None, Decimal('1234567.3456')]
   ```
   
   This seems to be vaguely on par with pyarrow convert:
   
   ```python
   import pyarrow as pa
   import decimal
   import numpy as np
   from nanoarrow.iterator import iter_py
   
   floats = np.random.random(int(1e6))
   items = [decimal.Decimal(item) for item in floats]
   array = pa.array(items)
   
   %timeit array.to_pylist()
   #> 799 ms ± 6.24 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
   
   %timeit list(iter_py(array))
   #> 431 ms ± 8.65 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to