From e61b49e7869ea6cd6644adcedfb176d443b56aa0 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Sun, 24 Apr 2022 11:53:03 -0400 Subject: [PATCH] Minor opt to cache tuple casting --- 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 d06ddfa11d..3141e5bbe7 100644 --- a/include/pybind11/numpy.h +++ b/include/pybind11/numpy.h @@ -645,8 +645,9 @@ class dtype : public object { 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; }