]>
Commit | Line | Data |
---|---|---|
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 | ||
22 | import datetime | |
23 | import decimal as _pydecimal | |
24 | import numpy as np | |
25 | import os | |
26 | import sys | |
27 | ||
28 | from cython.operator cimport dereference as deref | |
29 | from pyarrow.includes.libarrow cimport * | |
30 | from pyarrow.includes.common cimport PyObject_to_object | |
31 | cimport pyarrow.includes.libarrow as libarrow | |
32 | cimport cpython as cp | |
33 | ||
34 | # Initialize NumPy C API | |
35 | arrow_init_numpy() | |
36 | # Initialize PyArrow C++ API | |
37 | # (used from some of our C++ code, see e.g. ARROW-5260) | |
38 | import_pyarrow() | |
39 | ||
40 | ||
41 | MonthDayNano = NewMonthDayNanoTupleType() | |
42 | ||
43 | ||
44 | def 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 | ||
62 | def 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 | ||
81 | Type_NA = _Type_NA | |
82 | Type_BOOL = _Type_BOOL | |
83 | Type_UINT8 = _Type_UINT8 | |
84 | Type_INT8 = _Type_INT8 | |
85 | Type_UINT16 = _Type_UINT16 | |
86 | Type_INT16 = _Type_INT16 | |
87 | Type_UINT32 = _Type_UINT32 | |
88 | Type_INT32 = _Type_INT32 | |
89 | Type_UINT64 = _Type_UINT64 | |
90 | Type_INT64 = _Type_INT64 | |
91 | Type_HALF_FLOAT = _Type_HALF_FLOAT | |
92 | Type_FLOAT = _Type_FLOAT | |
93 | Type_DOUBLE = _Type_DOUBLE | |
94 | Type_DECIMAL128 = _Type_DECIMAL128 | |
95 | Type_DECIMAL256 = _Type_DECIMAL256 | |
96 | Type_DATE32 = _Type_DATE32 | |
97 | Type_DATE64 = _Type_DATE64 | |
98 | Type_TIMESTAMP = _Type_TIMESTAMP | |
99 | Type_TIME32 = _Type_TIME32 | |
100 | Type_TIME64 = _Type_TIME64 | |
101 | Type_DURATION = _Type_DURATION | |
102 | Type_INTERVAL_MONTH_DAY_NANO = _Type_INTERVAL_MONTH_DAY_NANO | |
103 | Type_BINARY = _Type_BINARY | |
104 | Type_STRING = _Type_STRING | |
105 | Type_LARGE_BINARY = _Type_LARGE_BINARY | |
106 | Type_LARGE_STRING = _Type_LARGE_STRING | |
107 | Type_FIXED_SIZE_BINARY = _Type_FIXED_SIZE_BINARY | |
108 | Type_LIST = _Type_LIST | |
109 | Type_LARGE_LIST = _Type_LARGE_LIST | |
110 | Type_MAP = _Type_MAP | |
111 | Type_FIXED_SIZE_LIST = _Type_FIXED_SIZE_LIST | |
112 | Type_STRUCT = _Type_STRUCT | |
113 | Type_SPARSE_UNION = _Type_SPARSE_UNION | |
114 | Type_DENSE_UNION = _Type_DENSE_UNION | |
115 | Type_DICTIONARY = _Type_DICTIONARY | |
116 | ||
117 | UnionMode_SPARSE = _UnionMode_SPARSE | |
118 | UnionMode_DENSE = _UnionMode_DENSE | |
119 | ||
120 | ||
121 | def _pc(): | |
122 | import pyarrow.compute as pc | |
123 | return pc | |
124 | ||
125 | ||
126 | # Assorted compatibility helpers | |
127 | include "compat.pxi" | |
128 | ||
129 | # Exception types and Status handling | |
130 | include "error.pxi" | |
131 | ||
132 | # Configuration information | |
133 | include "config.pxi" | |
134 | ||
135 | # pandas API shim | |
136 | include "pandas-shim.pxi" | |
137 | ||
138 | # Memory pools and allocation | |
139 | include "memory.pxi" | |
140 | ||
141 | # DataType, Field, Schema | |
142 | include "types.pxi" | |
143 | ||
144 | # Array scalar values | |
145 | include "scalar.pxi" | |
146 | ||
147 | # Array types | |
148 | include "array.pxi" | |
149 | ||
150 | # Builders | |
151 | include "builder.pxi" | |
152 | ||
153 | # Column, Table, Record Batch | |
154 | include "table.pxi" | |
155 | ||
156 | # Tensors | |
157 | include "tensor.pxi" | |
158 | ||
159 | # File IO | |
160 | include "io.pxi" | |
161 | ||
162 | # IPC / Messaging | |
163 | include "ipc.pxi" | |
164 | ||
165 | # Python serialization | |
166 | include "serialization.pxi" | |
167 | ||
168 | # Micro-benchmark routines | |
169 | include "benchmark.pxi" | |
170 | ||
171 | # Public API | |
172 | include "public-api.pxi" |