Skip to content
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

Python Compatibility TODO List #1

Open
13 of 17 tasks
klange opened this issue Jan 4, 2021 · 0 comments
Open
13 of 17 tasks

Python Compatibility TODO List #1

klange opened this issue Jan 4, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@klange
Copy link
Collaborator

klange commented Jan 4, 2021

Kuroko is essentially an incomplete implementation of Python with some quirks. This issue is intended to track what Kuroko is missing or unintentionally does differently.

  • Tuples: Are these really any different from lists without mutation? Look into also implementing CPython's freelists for small tuples, which probably requires some GC integration. Syntax support should be fairly straightforward: Detect TOKEN_COMMA in a grouping after an expression and switch to tuple processing.
  • if statements in comprehensions: Implement as an if branch that pops and decrements the iterator counter if expression is False?
  • print as a function: OP_PRINT is just a loxism and there's really no reason this couldn't be moved to a native function, including support for the various keyword arguments (end is particularly useful). This can happen right now? (Even inclusive of the string coercion...)
  • is: We only have == and there are semantic differences between is and ==. Also is not.
  • Various special methods: __get__/__set__ should be renamed to their Python counterparts of __getitem__/__setitem__, we're missing all of the operator ones (__add__, __eq__, etc.)... Marked done: Some of these aren't the same as in Python, but we have good overall coverage for operators.
  • Class fields: These are just generally useful for defining fixed members or defaults without an init, and also make nicely namespaced enums and whatnot.
  • Standard Library: Throwing this very large task in a single checkbox, but there's a lot of ground to cover even just for the basics.
  • Line feeds in statements: Inside of parens or brackets, line feeds should be accepted.
  • pass statement: We accept empty blocks, maybe we shouldn't? Still should have pass either way.
  • with ... as ...: I think this fairly straightforward? It's a scoping block that introduces a local from an expression. Slap a let on the line before and the typical Python use case makes sense of opening and reading a file into a variable and then closing the file (still need to support files going out of scope correctly closing/freeing, but that's a different issue). Marked done: VM still needs better support for early exceptions.
  • finally statement: Semantics for this are complicated.
  • Multiple arbitrary assignments: We can assign to multiple members with special syntax (foo.(a,b,c) = ...) and we can assign multiple variables in a let expression, but assignment to multiple arbitrary assignment targets is tricky without an AST.
  • async/await
    Coroutines in CPython are implemented in essentially the same ways generators, combined with an event loop that handles scheduling them. We have generators, we have real threads to use with to_thread, we should be able to build a compatible implementation of async/await and start pumping out coroutines.
  • asyncio module
  • yield from, yield expressions
  • Understand global/nonlocal in functions; global is probably a no-op, non-local may be useful as a static check that enforces resolution as an upvalue?
  • Recover the Python-compatible mode in the compiler.
@klange klange added the enhancement New feature or request label Jan 4, 2021
harjitmoe pushed a commit that referenced this issue Mar 26, 2021
Resync with upstream master.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant