by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 01 10:54

    dependabot-preview[bot] on cargo

    (compare)

  • Jun 01 10:54

    dependabot-preview[bot] on master

    Bump anyhow from 1.0.28 to 1.0.… (compare)

  • Jun 01 10:54
    dependabot-preview[bot] closed #318
  • Jun 01 10:07
    dependabot-preview[bot] synchronize #318
  • Jun 01 10:07

    dependabot-preview[bot] on cargo

    Bump anyhow from 1.0.28 to 1.0.… (compare)

  • Jun 01 10:07
    dependabot-preview[bot] edited #318
  • Jun 01 10:06
    dependabot-preview[bot] edited #318
  • Jun 01 10:06

    dependabot-preview[bot] on cargo

    (compare)

  • Jun 01 10:06

    dependabot-preview[bot] on master

    Bump bytesize from 1.0.0 to 1.0… (compare)

  • Jun 01 10:06
    dependabot-preview[bot] closed #317
  • Jun 01 09:57

    dependabot-preview[bot] on cargo

    (compare)

  • Jun 01 09:57

    dependabot-preview[bot] on master

    Bump regex from 1.3.7 to 1.3.9 … (compare)

  • Jun 01 09:57
    dependabot-preview[bot] closed #316
  • Jun 01 09:49

    dependabot-preview[bot] on cargo

    (compare)

  • Jun 01 09:49

    dependabot-preview[bot] on master

    Bump thiserror from 1.0.16 to 1… (compare)

  • Jun 01 09:49
    dependabot-preview[bot] closed #315
  • Jun 01 09:31
    dependabot-preview[bot] labeled #318
  • Jun 01 09:31
    dependabot-preview[bot] opened #318
  • Jun 01 09:31

    dependabot-preview[bot] on cargo

    Bump anyhow from 1.0.28 to 1.0.… (compare)

  • Jun 01 09:31
    dependabot-preview[bot] labeled #317
Rob Gilton
@rgilton
Can anyone tell me how to create an instance of python's None (not rust's Option::None -- makes it quite tricky to search the docs for!)
Omer Katz
@thedrow
None is a singleton in Python
You can't create an instance of it
Omer Katz
@thedrow
I think you can use the FFI definition if you really want to
but why would you?
Omer Katz
@thedrow

I implemented FromPyObject because I couldn't pass a UUID object to the uuid_v4 function (for example). It doesn't work anymore.
Should I be using RefCell or something?

impl<'p> FromPyObject<'p> for UUID {
        fn extract(obj: &'p PyAny) -> PyResult<Self> {
            let result: &UUID = obj.downcast()?;
            Ok(UUID {
                handle: result.handle,
            })
        }
    }

Oh I just need to implement clone...

David Hewitt
@davidhewitt
@rgilton @thedrow you can use Python::None to get a reference to Python's None singleton :)
@thedrow you should be able to #[derive(Clone)]
I also think &UUID will work as a function argument without needing Clone
Omer Katz
@thedrow

I also think &UUID will work as a function argument without needing Clone

It doesn't so it seems

@thedrow you should be able to #[derive(Clone)]

I'm not sure what that does

David Hewitt
@davidhewitt
Hmm ok, I'll open some PRs to fastuuid to share a couple suggestions in a bit
David Hewitt
@davidhewitt
@thedrow pushed a few suggestions!
David Hewitt
@davidhewitt
Also, turns out the &UUID function argument is a bug: PyO3/pyo3#940
Omer Katz
@thedrow
@davidhewitt not sure I understand, but then again I'm not sure I had enough coffee
Árni Dagur
@ArniDagur
Question: If I'm using Maturin to create my wheels, and wanted to bundle type stubs (PEP 561 and PEP484), would PyO3/maturin#258 have to be resolved?
If I were to write a .pyi file by hand, is there a way for me already to include it in the wheels?
David Hewitt
@davidhewitt
@ArniDagur are you using Maturing in "mixed rust/python" mode? I think pyi files in the python part might get bundled by maturin in that case (but haven't tested)
kangalioo
@kangalioo
Is it possible to gate features = ["extension-module"] and crate-type = ["cdylib"] behind a feature?
Ethan Smith
@ethanhs
for features, yes, for crate-type I think you can add "rlib" and it should work
kangalioo
@kangalioo

for features, yes

where could I find information on how to do that?

thanks for the answer btw
Ethan Smith
@ethanhs
@kangalioo You can have something like [feature]python = ["pyo3/extension-module"]
argh I'm on mobile so I don't think I can do multiline but you get the idea
an example that I know works is here:
kangalioo
@kangalioo
nice, thank you
Ethan Smith
@ethanhs
happy to help, let me know if you have questions!
perhaps this is something that would be good to include in the user guide...
matrixbot
@matrixbot

thesketh > <@gilescope:matrix.org> In reddit: https://www.reddit.com/r/rust/comments/gn97kn/pyo3_trouble_with_subclassing_from_python/

Hey, was there any solution to this? I've run into a similar problem

David Hewitt
@davidhewitt
I don't think an issue was ever posted. Could you please open one with a reproduction and I'll take a look when I have a moment?
matrixbot
@matrixbot
@gilescope:matrix.org Morning all, has anyone tried getting multiple rust dlls (that share common types) each wrapped in pyo3 talking to each other? I am looking at abi_stable_crates wondering if that may help rust play nicely with rust.
Dmitry Dygalo
@Stranger6667

Hello there!
I have a struct with a lifetime:

struct Foo<'a> {
    field: &'a str  // there are some more fields with that lifetimes & different types
}

I am wondering if it is possible to create a Python class, based on such a struct?
When I add the #[pyclass] macro to a wrapper it complains that generics are not allowed (which seems somehow misleading, since it is a lifetime, not generic):

#[pyclass]
struct FooWrapper<'a> {
    foo: Foo<'a>
}
error: #[pyclass] cannot have generic parameters

The idea is to pass some Python value to this class that will serve as a value for field. What could be possible approaches for such a case? My PyO3 version is 0.10.1, Rust 1.43.1

Yuji Kanagawa
@kngwyu
@Stranger6667 Unfortunately, Foo<'static> is the only possible workaround now...
1 reply
Ethan Smith
@ethanhs
So I've been thinking about replacing some Python multiprocessing with Rust threads, but currently I call into scipy.minimize in each process. Is there any issue with calling into Python from multiple threads concurrently?
David Hewitt
@davidhewitt
@ethanhs not sure that is even possible, because you'll need the GIL held in all the threads at the same time?
Ethan Smith
@ethanhs
@davidhewitt I think there are subinterpreter APIs which make it possible, but now that I think about it, maybe not
David Hewitt
@davidhewitt
Mmm yes I am vaguely aware of the subinterpreter APIs but haven't investigated them too hard. I have a feeling that they require you to use completely separate python objects with each interpreter. I'm not sure how well pyo3 currently supports them...
Ethan Smith
@ethanhs
@davidhewitt yeah, I would be running a completely different interpreter instantiation per thread
David Hewitt
@davidhewitt
Yeah it would be interesting to try it out! If you do, it would not be too huge a suprise if you run into pyo3-related issues. But imo it would be very worth reporting any you find so that we can fix them. It would be a very nice win for PyO3 if it enabled safe concurrent Python!
Ethan Smith
@ethanhs
Well it looks like I may not have to after all, I can probably just use nlopt
if I do end up trying it out I'll let you know
David Hewitt
@davidhewitt
👍
Oleksandr Soldatov
@captify-osoldatov
Hey there, just realize before writing that I was trying to do almost the same as @ethanhs, got an ability to add true parallelism for Python via rust will be great win! Great lib btw!
Ethan Smith
@ethanhs
@captify-osoldatov the hard part would be having multiple interpreters running in the same process
I think the building blocks are there, but using it may be pretty tricky
Oleksandr Soldatov
@captify-osoldatov
Yes, trying this at spare time, rust is still tricky for me itself, so struggling a bit :)
Ethan Smith
@ethanhs
Totally fair, there are plenty of people happy to help if you need it :)
Oleksandr Soldatov
@captify-osoldatov
Yeah, community is the best there !