Giter VIP home page Giter VIP logo

Comments (4)

MiguelMarcelino avatar MiguelMarcelino commented on June 20, 2024

Hello!
It would be an interesting feature to add, for sure. Currently, I am a bit delayed in delivering some features I have implemented for Py2Many (you can see my fork here). I am trying to find some time leftover to continue this work, as I believe the community could benefit from this. But I will add this suggestion to the list of things that would be interesting to implement!

from py2many.

j-fu avatar j-fu commented on June 20, 2024

Cool! The point here is that this would help to leverage the abilities of Julia concerning generic programming and multiple dispatch.
A function f(x,y)=... can be easily called with e.g. dual numbers, allowing to differentiate through it, while f(x,y)::Float64 would prevent this possibility. Coming from classical C++/typed languages I also had to unlearn the habit to annotate types everywhere just "to be sure"...

from py2many.

jayvdb avatar jayvdb commented on June 20, 2024

Just to clarify, if there are explicit type annotations in the Python, should they also be removed from the emitted Julia? My guess is you only want the types inferred by py2many to be removed from the output.

It would be very helpful if you could provide a sample input where not emitting the types allows for "better" Julia output.

Another approach to this may be to allow annotating the input Python with type Any, or a union of allowable types, either explicitly or within py2many, which would tell PyJL that it shouldn't emit a type annotation for a single type.

from py2many.

j-fu avatar j-fu commented on June 20, 2024

Thanks for coming back!
I tend to second your clarification, however I am so far not familiar with type annotations in python (switched to Julia before this became a thing...). I guess they are done to help Python to create faster code. If this is true (will try to read up on this), then the situation in Julia is a bit different.

For function calls, basically, Julia autodetects parameter types and emits specialized code without the need of annotation - very much like with a generic C++ header lib. The almost only case where you type-annotate parameters for Julia function is in oder to distinguish different implementations for different types.

For struct entries, the situation is different - here, type annotations are critical for performance.

I will try to come up with a more elaborated example to continue the discussion. May take some time as I am juggling too many balls currently...

from py2many.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.