dep-protobuf/python/google
Jie Luo 1eb4e5290a 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: 836264273
2025-11-24 09:59:08 -08:00
..
protobuf Python Proto scalar repeated numpy binding. 2025-11-24 09:59:08 -08:00
__init__.py drop-deprecated-pkg-resources-declare (#22442) 2025-07-11 11:09:55 -07:00