https://kotlinlang.org logo
Join SlackCommunities
Powered by
# python
  • p

    Piotr Krzemiński

    11/17/2020, 5:52 PM
    set the channel topic: Discussion related to Kotlin and Python interop
  • p

    Piotr Krzemiński

    11/17/2020, 5:52 PM
    set the channel description: Discussion related to Kotlin and Python interop
  • p

    Piotr Krzemiński

    11/17/2020, 5:53 PM
    set the channel topic: Discussion related to a future Kotlin and Python interop. See https://discuss.kotlinlang.org/t/idea-python-backend/19852
  • p

    Piotr Krzemiński

    11/17/2020, 5:53 PM
    set the channel description: Discussion related to a future Kotlin and Python interop. See https://discuss.kotlinlang.org/t/idea-python-backend/19852
  • p

    Piotr Krzemiński

    11/17/2020, 6:02 PM
    I'm currently working on mapping IR to Python AST. This file in the newest version gives a good grasp of the progress: https://github.com/krzema12/kotlin-1/blob/python-backend/python/experiments/out-ir.py. You can see some missing parts as e. g.
    visitExpression
    . This file's 99.9% is the standard lib (JS flavor), and you can see that the first function
    fold
    is generated almost entirely :) I work now by looking for places that are missing (
    visit...
    ) and adding a needed mapping. Quite slow, but surprisingly entertaining process to see the Python code appear bit by bit :)
    🔥 1
    c
    • 2
    • 2
  • c

    CLOVIS

    11/17/2020, 8:27 PM
    Hi! Thanks for the invite! I'm a student and I don't really have much time right now, but I'd love to be a part of this ^^ if you have anything not too complicated that you need help with, please tell me ^^
    👍 1
    p
    • 2
    • 1
  • p

    Piotr Krzemiński

    11/21/2020, 8:54 PM
    Quick update: this is already possible
    Copy code
    > tail -1 python/experiments/python.kt 
    fun returnString() = "Hello from Kotlin!"
    > tail -2 python/experiments/out_ir.py 
    def returnString():
        return 'Hello from Kotlin!'
    > cat python/experiments/consumer.py 
    from out_ir import returnString
    
    print(returnString())
    > python3.8 python/experiments/consumer.py 
    Hello from Kotlin!
    but for dead-simple functions - treat is a tracer bullet. I'm still working on getting the standard library to work. For now I just made it interpret without Python returning syntax error 🙂 so that the generated module can be loaded by Python and this little simple function can be invoked. More importantly, I got in touch with @Roman Artemev [JB] from Kotlin compiler's team who gave me directions where to go next, like creating black-box tests. Roman is super-helpful, a pleasure to learn about Kotlin internals from him. So called 'box tests' are a bunch of high-level tests, some of them platform-specific, and some of them platform-agnostic. Ultimately I'm aiming at making all platform-agnostic box tests pass, and short-term I'll use this test infra to test against some simpler cases. As soon as simple functions using Kotlin's stdlib work properly, it will be another nice milestone.
    🔥 3
    c
    m
    s
    • 4
    • 8
  • p

    Piotr Krzemiński

    11/23/2020, 9:40 PM
    box test infra for Python works (Python interpreter is in place) - *4429*/5368 tests failed 🙂 without the interpreter, *4513*/5368 were failing so the current Python backend implementation turns 84 tests to green - long way ahead to go from 4429 to 0 😄 anyway, the bottom line is that we now some way to measure the progress. See also https://github.com/krzema12/kotlin-1/blob/python-backend/python/README.md#test-stats
    🚀 3
  • p

    Piotr Krzemiński

    01/27/2021, 12:42 PM
    Not much happening in the project because this got my attention: https://github.com/krzema12/kotlin-rpc . Sort of more in line what I need daily. I'm hoping to get back to the Python thing one day :) I cannot make any commitments, though.
    💪 2
    m
    • 2
    • 1
  • p

    Piotr Krzemiński

    05/14/2021, 5:51 PM
    Revisiting the project together with @SerVB 🎉 let's see how far we can push it this time. Will update here once we reach some significant milestone.
    🎉 1
    ➕ 1
  • m

    martmists

    07/03/2021, 4:53 PM
    Has anyone documented what was needed to support Python? I'm interested in implementing other languages, but the lack of documentation makes it incredibly difficult to even find out where to start
    s
    • 2
    • 3
  • p

    Piotr Krzemiński

    07/15/2021, 7:56 PM
    Easier to work with (generate and read), and I think pyc bytecode is tied to CPython implementation while on source code level an implementation-agnostic Python code can be written. If there's any good reason for generating Python bytecode (even if only for CPython), please share it - it's never too late :)
  • p

    Piotr Krzemiński

    07/16/2021, 11:50 AM
    FYI, renamed the repo to https://github.com/krzema12/kotlin-python
    K 2
  • s

    SerVB

    07/19/2021, 10:26 AM
    Now we have a special channel for discussing kotlin2python development and internals: #python-contributors
  • p

    Piotr Krzemiński

    11/13/2021, 7:53 PM
    here's a summary of the first year that passed in the project: https://discuss.kotlinlang.org/t/idea-python-backend/19852/13?u=krzema12
    🎉 1
  • b

    Big Chungus

    12/01/2021, 10:48 AM
    This is probably not related to this channel, but I have no better idea where to ask. I've been trying to wrap my head around python list slicing assignment, but with very limited success. Could someone help me convert these two snippets in thread to Kotlin (ir python without list slicing) or at least give me some pointers? Much appreciated!
    s
    • 2
    • 20
  • p

    Piotr Krzemiński

    12/19/2021, 5:55 PM
    FYI, a thread on Reddit: https://www.reddit.com/r/Kotlin/comments/rjvngz/python_backend_for_kotlin/
    👏 2
  • p

    Piotr Krzemiński

    12/23/2021, 8:06 AM
    When working on introducing our stdlib, I found myself removing a lot of Python backend code just to get things not failing at runtime. The output is of course far from correct. It's just painful to work on it now, with the current level of mess 🤷 😆 now I see your pain @SerVB. That's why I think we should really invest into cleaning things up and understanding everything that happens in our Python backend. I'm shelving the stdlib thing and will focus first on removing commented and other dead code, e. g. I suspect some lowerings are not needed (either at all or not yet) in our case. It may take us like 3 months, but I see it as an investment into future development speed.
    🙏 1
    👍 1
    🆒 1
    • 1
    • 1
  • a

    andylamax

    12/26/2021, 5:35 AM
    Just out of curioisty (I am a total compilers noob) Is this Python Backend consuming Frontend IR?? also Is the FIR being passed through LLVM? Like other Kotlin/Native targets?? or is it own thing like the Kotlin/JS backend?
    d
    p
    l
    • 4
    • 15
  • m

    martmists

    05/02/2022, 10:30 PM
    As a quick status update from my end, I've been working on a KSP processor and Gradle plugin for KNative interop with the CPython API over here: https://github.com/Martmists-GH/kpy-plugin This is different from the kotlin-python project, which aims to implement a python target similar to Kotlin/JS While it still has some small problems, it seems to mostly be functioning correctly, so if anyone wants to try it out here it is.
    🆒 5
    p
    • 2
    • 3
  • p

    Piotr Krzemiński

    05/06/2022, 5:57 AM
    FYI, we're pausing our efforts around kotlin-python project, due to lack of resources and still huge amount of work needed to make it even an MVP. Huge kudos to @SerVB who consistently contributed with great improvements over the last year. I'm not removing the repo, hopefully one day it will be possible to resume the project. If anyone's interested, I'm happy to give you an introduction how to contribute and iterate on the project.
    🙏 3
    😿 7
    b
    m
    • 3
    • 2
  • s

    SrSouza

    06/22/2022, 10:47 PM
    Hi folks, just for curiosity, you folks think that Python would someday, when it get more stable be a official Kotlin target?
    p
    • 2
    • 2
  • n

    Nathan Fallet

    11/18/2023, 1:13 PM
    Hi! Just had the same idea today and saw that a work is already in progress. Is it still ongoing? If yes, what is the status and what are the plans? I’m willing to contribute on this as well!
    p
    • 2
    • 3
  • j

    Julius

    11/29/2023, 9:19 AM
    Maybe this is a naive idea, but could a simple kotlin-python compiler target be created by using the native targets and wrapping those with python bindings automatically?
    p
    • 2
    • 1
  • e

    Edward Kauna

    05/09/2024, 6:39 PM
    what is the roadmap to learning python and django?
    y
    • 2
    • 2
  • e

    Edward Kauna

    05/13/2024, 6:27 AM
    if you want to develop an application that when input images and videos, all similar images and videos are output, how would you propose to go about it?
  • e

    elect

    05/16/2024, 8:59 AM
    sorry for the spam/advertising, but in SciJava lately they have been working on Appose, to have jvm/python intercommunication
  • m

    Marcos Boyington

    10/29/2024, 4:50 PM
    I filed an official issue in youtrack @ https://youtrack.jetbrains.com/issue/KT-72533/Kotlin-Universal-Kotlin-for-every-major-environment & linked to here - someone made a good point that with Python being so popular with ML, now could be a good time to ramp back up on the project
    p
    • 2
    • 1
  • m

    Marcos Boyington

    10/29/2024, 4:55 PM
    if compiler experts could get it to the point of supporting
    expect / actual
    as other KMP languages, & support interop with python (e.g. similar to
    kotlinx.cinterop.CPointer
    ), I'd be happy to jump in & help starting to implement native libs,e.g. collections & coroutines
  • m

    Marcos Boyington

    10/29/2024, 5:15 PM
    Call me naive, but kotlin-to-python with
    expect / actual
    support (with ability to call python libs) & coroutine support & collections support, is not just an MVP, it's completely usable