Skip to content

Commit

Permalink
WIP: Update 'inactive_overload_cache' key
Browse files Browse the repository at this point in the history
Instead of just the function name, use '__qualname__.name'.
  • Loading branch information
BetsyMcPhail committed Jan 16, 2020
1 parent 0a0b0a1 commit 9fd21ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -2411,13 +2411,16 @@ inline function get_type_overload(const void *this_ptr, const detail::type_info
if (!self)
return function();
handle type = self.get_type();
auto key = std::make_pair(type.ptr(), name);
/* N.B. This uses `__qualname__.name` instead of `name`
to resolve pybind11#1922. */
auto full_name = type.attr("__qualname__").cast<std::string>() + "." + name;
auto key = std::make_pair(type.ptr(), full_name.c_str());

/* Cache functions that aren't overloaded in Python to avoid
many costly Python dictionary lookups below */
auto &cache = detail::get_internals().inactive_overload_cache;
if (cache.find(key) != cache.end())
return function();
//if (cache.find(key) != cache.end())
// return function();

function overload = getattr(self, name, function());
if (overload.is_cpp_function()) {
Expand Down

0 comments on commit 9fd21ae

Please sign in to comment.