]> git.proxmox.com Git - ceph.git/blame - ceph/src/arrow/python/pyarrow/lib.pyx
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / python / pyarrow / lib.pyx
CommitLineData
1d09f67e
TL
1# Licensed to the Apache Software Foundation (ASF) under one
2# or more contributor license agreements. See the NOTICE file
3# distributed with this work for additional information
4# regarding copyright ownership. The ASF licenses this file
5# to you under the Apache License, Version 2.0 (the
6# "License"); you may not use this file except in compliance
7# with the License. You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing,
12# software distributed under the License is distributed on an
13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14# KIND, either express or implied. See the License for the
15# specific language governing permissions and limitations
16# under the License.
17
18# cython: profile = False
19# cython: nonecheck = True
20# distutils: language = c++
21
22import datetime
23import decimal as _pydecimal
24import numpy as np
25import os
26import sys
27
28from cython.operator cimport dereference as deref
29from pyarrow.includes.libarrow cimport *
30from pyarrow.includes.common cimport PyObject_to_object
31cimport pyarrow.includes.libarrow as libarrow
32cimport cpython as cp
33
34# Initialize NumPy C API
35arrow_init_numpy()
36# Initialize PyArrow C++ API
37# (used from some of our C++ code, see e.g. ARROW-5260)
38import_pyarrow()
39
40
41MonthDayNano = NewMonthDayNanoTupleType()
42
43
44def cpu_count():
45 """
46 Return the number of threads to use in parallel operations.
47
48 The number of threads is determined at startup by inspecting the
49 ``OMP_NUM_THREADS`` and ``OMP_THREAD_LIMIT`` environment variables.
50 If neither is present, it will default to the number of hardware threads
51 on the system. It can be modified at runtime by calling
52 :func:`set_cpu_count()`.
53
54 See Also
55 --------
56 set_cpu_count : Modify the size of this pool.
57 io_thread_count : The analogous function for the I/O thread pool.
58 """
59 return GetCpuThreadPoolCapacity()
60
61
62def set_cpu_count(int count):
63 """
64 Set the number of threads to use in parallel operations.
65
66 Parameters
67 ----------
68 count : int
69 The number of concurrent threads that should be used.
70
71 See Also
72 --------
73 cpu_count : Get the size of this pool.
74 set_io_thread_count : The analogous function for the I/O thread pool.
75 """
76 if count < 1:
77 raise ValueError("CPU count must be strictly positive")
78 check_status(SetCpuThreadPoolCapacity(count))
79
80
81Type_NA = _Type_NA
82Type_BOOL = _Type_BOOL
83Type_UINT8 = _Type_UINT8
84Type_INT8 = _Type_INT8
85Type_UINT16 = _Type_UINT16
86Type_INT16 = _Type_INT16
87Type_UINT32 = _Type_UINT32
88Type_INT32 = _Type_INT32
89Type_UINT64 = _Type_UINT64
90Type_INT64 = _Type_INT64
91Type_HALF_FLOAT = _Type_HALF_FLOAT
92Type_FLOAT = _Type_FLOAT
93Type_DOUBLE = _Type_DOUBLE
94Type_DECIMAL128 = _Type_DECIMAL128
95Type_DECIMAL256 = _Type_DECIMAL256
96Type_DATE32 = _Type_DATE32
97Type_DATE64 = _Type_DATE64
98Type_TIMESTAMP = _Type_TIMESTAMP
99Type_TIME32 = _Type_TIME32
100Type_TIME64 = _Type_TIME64
101Type_DURATION = _Type_DURATION
102Type_INTERVAL_MONTH_DAY_NANO = _Type_INTERVAL_MONTH_DAY_NANO
103Type_BINARY = _Type_BINARY
104Type_STRING = _Type_STRING
105Type_LARGE_BINARY = _Type_LARGE_BINARY
106Type_LARGE_STRING = _Type_LARGE_STRING
107Type_FIXED_SIZE_BINARY = _Type_FIXED_SIZE_BINARY
108Type_LIST = _Type_LIST
109Type_LARGE_LIST = _Type_LARGE_LIST
110Type_MAP = _Type_MAP
111Type_FIXED_SIZE_LIST = _Type_FIXED_SIZE_LIST
112Type_STRUCT = _Type_STRUCT
113Type_SPARSE_UNION = _Type_SPARSE_UNION
114Type_DENSE_UNION = _Type_DENSE_UNION
115Type_DICTIONARY = _Type_DICTIONARY
116
117UnionMode_SPARSE = _UnionMode_SPARSE
118UnionMode_DENSE = _UnionMode_DENSE
119
120
121def _pc():
122 import pyarrow.compute as pc
123 return pc
124
125
126# Assorted compatibility helpers
127include "compat.pxi"
128
129# Exception types and Status handling
130include "error.pxi"
131
132# Configuration information
133include "config.pxi"
134
135# pandas API shim
136include "pandas-shim.pxi"
137
138# Memory pools and allocation
139include "memory.pxi"
140
141# DataType, Field, Schema
142include "types.pxi"
143
144# Array scalar values
145include "scalar.pxi"
146
147# Array types
148include "array.pxi"
149
150# Builders
151include "builder.pxi"
152
153# Column, Table, Record Batch
154include "table.pxi"
155
156# Tensors
157include "tensor.pxi"
158
159# File IO
160include "io.pxi"
161
162# IPC / Messaging
163include "ipc.pxi"
164
165# Python serialization
166include "serialization.pxi"
167
168# Micro-benchmark routines
169include "benchmark.pxi"
170
171# Public API
172include "public-api.pxi"