mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
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: 836264273 |
||
|---|---|---|
| .. | ||
| protobuf | ||
| __init__.py | ||