Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
ccc69f91
Commit
ccc69f91
authored
Oct 20, 2016
by
Ivan Smirnov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache direct converters in the generic type caster
parent
cbbb7830
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
include/pybind11/cast.h
+4
-7
No files found.
include/pybind11/cast.h
View file @
ccc69f91
...
@@ -157,7 +157,8 @@ inline void keep_alive_impl(handle nurse, handle patient);
...
@@ -157,7 +157,8 @@ inline void keep_alive_impl(handle nurse, handle patient);
class
type_caster_generic
{
class
type_caster_generic
{
public
:
public
:
PYBIND11_NOINLINE
type_caster_generic
(
const
std
::
type_info
&
type_info
)
PYBIND11_NOINLINE
type_caster_generic
(
const
std
::
type_info
&
type_info
)
:
typeinfo
(
get_type_info
(
type_info
,
false
)),
tindex
(
type_info
)
{
}
:
typeinfo
(
get_type_info
(
type_info
,
false
)),
direct_conversions
(
get_internals
().
direct_conversions
[
std
::
type_index
(
type_info
)])
{
}
PYBIND11_NOINLINE
bool
load
(
handle
src
,
bool
convert
)
{
PYBIND11_NOINLINE
bool
load
(
handle
src
,
bool
convert
)
{
if
(
!
src
)
if
(
!
src
)
...
@@ -297,21 +298,17 @@ public:
...
@@ -297,21 +298,17 @@ public:
protected
:
protected
:
const
type_info
*
typeinfo
=
nullptr
;
const
type_info
*
typeinfo
=
nullptr
;
std
::
type_index
tindex
;
const
std
::
vector
<
bool
(
*
)(
PyObject
*
,
void
*&
)
>&
direct_conversions
;
void
*
value
=
nullptr
;
void
*
value
=
nullptr
;
object
temp
;
object
temp
;
bool
load_direct
(
handle
src
,
bool
convert
)
{
bool
load_direct
(
handle
src
,
bool
convert
)
{
if
(
convert
)
{
if
(
convert
)
{
auto
&
direct
=
get_internals
().
direct_conversions
;
for
(
auto
&
converter
:
direct_conversions
)
{
auto
it
=
direct
.
find
(
tindex
);
if
(
it
!=
direct
.
end
())
{
for
(
auto
&
converter
:
it
->
second
)
{
if
(
converter
(
src
.
ptr
(),
value
))
if
(
converter
(
src
.
ptr
(),
value
))
return
true
;
return
true
;
}
}
}
}
}
return
false
;
return
false
;
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment