From 82455a41fdc9cabf6a0eeba2071dc8a0c8cac4c1 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Sun, 24 Apr 2022 14:46:39 -0400 Subject: [PATCH] Minor opt to cache tuple casting (#3894) --- include/pybind11/numpy.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pybind11/numpy.h b/include/pybind11/numpy.h index 2713e13a..b8ba2259 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -647,8 +647,9 @@ private: for (auto field : attr("fields").attr("items")()) { auto spec = field.cast(); auto name = spec[0].cast(); - auto format = spec[1].cast()[0].cast(); - auto offset = spec[1].cast()[1].cast(); + auto spec_fo = spec[1].cast(); + auto format = spec_fo[0].cast(); + auto offset = spec_fo[1].cast(); if ((len(name) == 0u) && format.kind() == 'V') { continue; }