You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Joris Van den Bossche (Jira)" <ji...@apache.org> on 2022/03/08 13:40:00 UTC

[jira] [Commented] (ARROW-15853) [Python][Docs] Describe behavior of pyarrow.array()

    [ https://issues.apache.org/jira/browse/ARROW-15853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17502946#comment-17502946 ] 

Joris Van den Bossche commented on ARROW-15853:
-----------------------------------------------

Similar issue about this from [~amol-] at ARROW-12666

> [Python][Docs] Describe behavior of pyarrow.array(<mutable zero-copy source>)
> -----------------------------------------------------------------------------
>
>                 Key: ARROW-15853
>                 URL: https://issues.apache.org/jira/browse/ARROW-15853
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Documentation, Python
>            Reporter: David Li
>            Priority: Major
>
> {noformat}
> Python 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:25:18) [GCC 9.4.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import numpy as np
> >>> import pyarrow as pa
> >>> ndarr = np.array(range(10))
> >>> arr = pa.array(ndarr)
> >>> arr
> <pyarrow.lib.Int64Array object at 0x7efdf7974100>
> [
>   0,
>   1,
>   2,
>   3,
>   4,
>   5,
>   6,
>   7,
>   8,
>   9
> ]
> >>> ndarr[0] = 10
> >>> arr
> <pyarrow.lib.Int64Array object at 0x7efdf7974100>
> [
>   10,
>   1,
>   2,
>   3,
>   4,
>   5,
>   6,
>   7,
>   8,
>   9
> ]
> {noformat}
> While this behavior makes perfect sense with some consideration, it may surprise people. We should document which sources can be zero-copied, and note that in these cases, modifications to the underlying array will affect the PyArrow array (even though this is normally not the case).



--
This message was sent by Atlassian Jira
(v8.20.1#820001)