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

sage.libs.ecl: Make it possible to convert Python strings to Lisp strings #30105

Closed
mkoeppe opened this issue Jul 10, 2020 · 22 comments
Closed

Comments

@mkoeppe
Copy link
Member

mkoeppe commented Jul 10, 2020

sage.libs.ecl exposes no Python function that converts a Python string to a Lisp string as an EclObject.

(python_to_ecl, which is used by EclObject.__init__, handles strings by READing from them, so EclObject("abc") returns an interned symbol, not a string.)

We add an argument to python_to_ecl and EclObject.__init__ that controls how strings are handled.

Depends on #30106

CC: @nbruin @dimpase @spaghettisalat @mwageringel

Component: interfaces

Author: Matthias Koeppe

Branch/Commit: b6cea1a

Reviewer: Dima Pasechnik

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

@mkoeppe mkoeppe added this to the sage-9.2 milestone Jul 10, 2020
@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

comment:2

In fact, perhaps it would also make sense to add an optional argument to python_to_ecl and EclObject.__init__ that controls whether Python strings (which may also be nested in lists etc.) are merely converted (using the new function) or READ from.

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title sage.libs.ecl: Add Python function ecl_make_string sage.libs.ecl: Make it possible to convert Python strings to Lisp strings Jul 10, 2020
@dimpase
Copy link
Member

dimpase commented Jul 10, 2020

comment:4

how about making use of things like ecl_to_double() to send data between Python and Maxima?

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

comment:5

Replying to @dimpase:

how about making use of things like ecl_to_double() to send data between Python and Maxima?

This is the opposite direction of conversion, and these functions are already used in ecl_to_python.

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

comment:6

Replying to @mkoeppe:

In fact, perhaps it would also make sense to add an optional argument to python_to_ecl and EclObject.__init__ that controls whether Python strings (which may also be nested in lists etc.) are merely converted (using the new function) or READ from.

I have revised the ticket description accordingly.

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

Author: Matthias Koeppe

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

Commit: 70a6351

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

New commits:

70a6351sage.libs.ecl.EclObject.__init__: Add optional argument read_strings

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

comment:10

This works but the unicode handling needs to be improved.

sage: from sage.libs.ecl import *
sage: fire = EclObject('🔥', False)
sage: fire
<ECL: "🔥">
sage: _length = ecl_eval('''#'length''')
sage: _length(fire)
<ECL: 4>
sage: _type_of = ecl_eval('''#'type-of''')
sage: _type_of(fire)
<ECL: (SIMPLE-ARRAY BASE-CHAR (4))>

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 10, 2020

comment:11

For unicode issues, see #30106.

Let's ignore them here to keep the ticket limited in scope.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 11, 2020

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

12447bcreject old makeinfo
a3e0ecaadd upstream fix from MR 215
89b006badd the patch from upstream MR 214
0b77737add upstream MR 216 (to fix cygwin fork)
8ca1c0eMerge tag '9.2.beta2' into t/22191/public/packages/ecl20
f82c716Commit 75877dd8 from upstream
2d87ee3Merge commit 'f82c716fdf9c6e91a07166d36b6329a15ecfb41d' of git://trac.sagemath.org/sage into t/30106/sage_libs_ecl__fix_unicode_handling
828a727Add doctests
0bfaccfMerge branch 't/30106/sage_libs_ecl__fix_unicode_handling' into t/30105/sage_libs_ecl__add_python_function_ecl_make_string
dd27b33sage.libs.ecl: Update uses of python_to_ecl

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 11, 2020

Changed commit from 70a6351 to dd27b33

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 11, 2020

Dependencies: #30106

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2020

Branch pushed to git repo; I updated commit sha1. New commits:

99b894aprint_objects: Handle unicode
59dd62becl_eval: Make docstring raw
b6cea1aMerge branch 't/30106/sage_libs_ecl__fix_unicode_handling' into t/30105/sage_libs_ecl__add_python_function_ecl_make_string

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 12, 2020

Changed commit from dd27b33 to b6cea1a

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 12, 2020

comment:15

Merged latest version of #30106. Needs review

@dimpase
Copy link
Member

dimpase commented Jul 18, 2020

Reviewer: Dima Pasechnik

@dimpase
Copy link
Member

dimpase commented Jul 18, 2020

comment:16

lgtm

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 18, 2020

comment:17

Thanks!

@vbraun
Copy link
Member

vbraun commented Jul 28, 2020

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