Skip to content

Using PythonCall within Julia modules #57

Closed
@haberdashPI

Description

@haberdashPI

First of all, thanks for working on this, I really appreciate these improvements from PyCall.

Seems like calling pyimport from the top level of a module in precompiled code would create issues.

In PyCall, the following approach is recommended:

const scipy_opt = PyNULL()

function __init__()
    copy!(scipy_opt, pyimport_conda("scipy.optimize", "scipy"))
end

end

I think the equivalent in PythonCall would be

const scipy_opt = pynew()

function __init__()
   pycopy!(scipy_opt, pyimport("scipy.optimize"))
end

It would be worth documenting this somewhere. Obviously a lot of folks are going to be coming from PyCall (and will know to be mindful of this) but it would be better to make this fact explicit, or indicate that this isn't required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions