Commit 1eb4e52
Python Proto scalar repeated numpy binding.
Add __array__ magic method to scalar repeated field. The default returned dtype of numpy/tensorflow usages like np.arrary() np.asarray() will be change.
Cpp_Type | np.array() dtype | Old tf.reshape() dtype | New dtype
float. | float64/float64 | float32/float32. | float32
double. | float64/float64. | float32/float32. | float64
int32. | int64/float64. | int32/float32. | int32
int64. | int64/float64. | int32/float32. | int64
uint32. | int64/float64. | int32/float32. | uint32
uint64. | int64/float64. | int32/float32. | uint64
bool. | bool/float64. | bool/float32. | bool
enum | int64/float64 | int32/float32 | int32
string | U/float64 | string/float32 | U (Unicode string)
bytes | S/float64 | string/float32. | S (Byte string)
Performance improvement:
For non-string repeated:
-upb/cpp are about 50-100 times faster.
-pure python is ~3x times faster.
For string repeated: numbers are noise, no regression (maybe a slight win)
PiperOrigin-RevId: 8362642731 parent 787a221 commit 1eb4e52
File tree
5 files changed
+822
-4
lines changed- python
- google/protobuf
- internal
- numpy
- pyext
5 files changed
+822
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | | - | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| 114 | + | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
202 | 205 | | |
203 | 206 | | |
204 | 207 | | |
205 | | - | |
| 208 | + | |
| 209 | + | |
206 | 210 | | |
207 | 211 | | |
208 | 212 | | |
209 | 213 | | |
210 | 214 | | |
211 | 215 | | |
212 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
213 | 249 | | |
214 | 250 | | |
215 | 251 | | |
| |||
0 commit comments