Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement conversion C++ <-> str #23857

Closed
jdemeyer opened this issue Sep 14, 2017 · 19 comments
Closed

Implement conversion C++ <-> str #23857

jdemeyer opened this issue Sep 14, 2017 · 19 comments

Comments

@jdemeyer
Copy link

In order to clean up the wrapping of C++ code, we need proper conversion of C++ objects to and from Python strings. This is currently done in a hacky way in ccobject.h but it can be done more cleanly using Cython's support for C++ templates.

In particular, we implement:

  • ccrepr() to convert any C++ object to str
  • ccreadstr() to convert a str to a C++ object

We intentionally use the words repr and read because this is using string input/output (operators << and >>).

Moreover, this new function will support both Python 2 and Python 3. In the latter case, the filesystem encoding is used.

CC: @embray

Component: python3

Author: Jeroen Demeyer

Branch/Commit: b7127ce

Reviewer: Vincent Delecroix

Issue created by migration from https://trac.sagemath.org/ticket/23857

@jdemeyer jdemeyer added this to the sage-8.1 milestone Sep 14, 2017
@jdemeyer

This comment has been minimized.

@jdemeyer jdemeyer changed the title Implement cppstr() to convert any C++ object to str Implement ccstr() to convert any C++ object to str Sep 14, 2017
@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@jdemeyer jdemeyer changed the title Implement ccstr() to convert any C++ object to str Implement conversion C++ <-> str Sep 14, 2017
@jdemeyer
Copy link
Author

@jdemeyer
Copy link
Author

Commit: 5952084

@jdemeyer
Copy link
Author

New commits:

5952084Implement conversion C++ <-> str

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 14, 2017

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

88d9dedImplement conversion C++ <-> str

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 14, 2017

Changed commit from 5952084 to 88d9ded

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 14, 2017

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

8598ab6Implement conversion C++ <-> str

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 14, 2017

Changed commit from 88d9ded to 8598ab6

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2017

Changed commit from 8598ab6 to b7127ce

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 15, 2017

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b7127ceImplement conversion C++ <-> str

@jdemeyer

This comment has been minimized.

@jdemeyer

This comment has been minimized.

@videlec
Copy link
Contributor

videlec commented Sep 29, 2017

comment:12

This is nice! How did you test the Python3 version?

@jdemeyer
Copy link
Author

comment:13

Replying to @videlec:

This is nice! How did you test the Python3 version?

To be honest, I did not. I am just hoping that it works.

@videlec
Copy link
Contributor

videlec commented Sep 30, 2017

Reviewer: Vincent Delecroix

@vbraun
Copy link
Member

vbraun commented Oct 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants