Skip to content

Implement conversion C++ <-> str #23857

@jdemeyer

Description

@jdemeyer

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions