Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11_abseil
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_abseil
Commits
a2223619
Commit
a2223619
authored
Feb 19, 2021
by
Ken Oslund
Committed by
Copybara-Service
Feb 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Internal change
PiperOrigin-RevId: 358426961
parent
75fe331e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
README.md
+25
-0
No files found.
README.md
View file @
a2223619
...
@@ -235,6 +235,31 @@ structs (ie, any type which you created bindings for using
...
@@ -235,6 +235,31 @@ structs (ie, any type which you created bindings for using
`pybind11::class_<...>`
) can be used, but unique_ptrs to converted types (eg,
`pybind11::class_<...>`
) can be used, but unique_ptrs to converted types (eg,
`int`
,
`string`
,
`absl::Time`
,
`absl::Duration`
, etc) cannot be used.
`int`
,
`string`
,
`absl::Time`
,
`absl::Duration`
, etc) cannot be used.
### absl::StatusCode
The
`status`
module provides
`pybind11::enum_`
bindings for
`absl::StatusCode`
.
These use python constant style- eg
`status.StatusCode.OK`
,
`status.StatusCode.CANCELLED`
, etc.
Warning: Pybind enums are their own type, and will never compare equally to
integers due to being a different type, regardless of their value. In particular,
note that the
[
status proto
](
http://google3/util/task/status.proto
)
`code`
field is an integer, so it will never directly compare as equal to a
`StatusCode`
. To fix this, convert an integer to a
`StatusCode`
or vice-versa.
```
python
status_code
=
0
# An integer.
if
status_code
==
status
.
StatusCode
.
OK
:
# Wrong: always evaluates to false.
...
if
status
.
StatusCode
(
status_code
)
==
status
.
StatusCode
.
OK
:
# Correct.
...
if
status_code
==
int
(
status
.
StatusCode
.
OK
):
# Also correct.
...
```
### Aliasing parts of the status module
### Aliasing parts of the status module
The need to import the
`status`
module can be eliminated by aliasing the parts
The need to import the
`status`
module can be eliminated by aliasing the parts
...
...
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