-
Notifications
You must be signed in to change notification settings - Fork 187
allow custom pytype return values #20
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if this needed to be handled differently given the above extension to pytype_query, so I left is alone
|
Thanks! Perhaps Also, maybe (What I had in mind for #9 was more like an automatic mapping of a Julia composite type to a Python composite type with the same fields, which is different from this.) |
|
Thanks, I'll update when I have time. My thought was that an Array would be much faster for iteration (which will happen much more often than insertion), so I think I'll keep it the same, but I'll also add a check for duplicates to mimic a Dict. |
|
Sounds good. |
example usage (for SymPy):
type Sym
x::PyCall.PyObject
end
Sym(s::Sym) = s
convert(::Type{Sym}, o::PyCall.PyObject) = Sym(o)
PyCall.pytype_query_add(sympy.basic[Basic], Sym)
|
OK. This should be set. As an example, note that this would have allowed BigFloat support to be added without editing PyCall (except perhaps for adding finalizer support). This would by done by adding to pytype_mapping(PyCall.mpf, BigFloat)
pytype_mapping(PyCall.mpc, Complex{BigFloat})instead of adding it directly to |
|
bump @stevengj |
|
Sorry about the delay. I'm on vacation this week with family and may not get to PyCall until I get back in the last week of June. |
allow custom pytype return values
this extends
pytype_query()to allow the user to add custom type mappings.example usage (based upon SymPy):
type Sym x::PyCall.PyObject end Sym(s::Sym) = s convert(::Type{Sym}, o::PyCall.PyObject) = Sym(o) PyCall.pytype_query_add(sympy.basic[Basic], Sym)note: I see this would address item 3 in #9