Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Off the top of my head, it lacks decent support for functional programming (like multi-line lambdas - pretty basic functionality even for a non-functional-oriented language!), properly supported static typing, proper multithreading, decent performance (in the main implementation)...


> like multi-line lambdas - pretty basic functionality even for a non-functional-oriented language!

Lambdas with one or more statements instead of a single expression (the actual limitation: “multi-line” is a misnomer) are only an issue because python is a strongly statement-oriented imperative language, and not expression-oriented like most functional and some other languages.


Functions are first-class objects. If you want a multi-line lambda thats just a function.


> Functions are first-class objects. If you want a multi-line lambda thats just a function.

Yes, lambdas are just anonymous functions that are restricted to a single expression, no statements. This is a problem for programming in functional style, because python idiomatically uses statements a lot, and doing a named definition for a single use function is more verbose and less readable in mant cases.


My stylistic advice in that case would be to name it _lambda() (note the underscore that solves keyword issues). Though I don't disagree.


It’s gross to have a function floating off somewhere that has no true reuse value at all and doesn’t live close to where it is used.

I like Python but this is probably my biggest gripe.


You can define a function anywhere, including in the scope of another function. So it doesn't need to be floating somewhere far away from where it's used. (This is the idiomatic way to write decorators, for example.)


Why do your anonymous functions have to live far from where they're used? What's the non-aesthetic difference between this:

    def func(g_func, a, b):
        g_func(a, b)

    def scope():
        c = "c"
        def anon(a, b):
            print(a, b, c)
        print(id(anon))
        return func(anon, "a", "b")
and this:

    def func(g_func, a, b):
        g_func(a, b)

    def scope():
        # NOTE: The `|a, b|: (...)` syntax is made up
        c = "c"
        return func(
            |a, b|: (
                print(a, b, c)
            ),
            "a", "b"
        )
?

Note that the `anon` function in `scope` is only compiled once. You can verify this by copying the first version to a file named `temp.py` and then running `python -m dis temp.py`. You can also run `scope()` twice in a row and see that the same object ID is printed both times.

That said, for purely aesthetic reasons, I would like it if Python had some kind of syntax like version 2, but that's tricky with significant whitespace, and I've never found the lack of such syntax to be particularly limiting in Python.


I think its gross to try to inline a multiline anonymous function usually inside of what should just be a function call.


I mean, it is Python, if you are using it you aren’t aiming to be super-lean, right?

Apparently it is possible to delete a function.

https://stackoverflow.com/questions/10367414/delete-function


You can delete references to any object in Python, including functions:

    >>> def f(): None
    ...
    >>> del f
but it's pointless to try to manually manage memory in Python in most cases. If you're processing huge amounts of data, there are probably better approaches than using `del` and/or `gc.collect()` to keep memory usage down (like batching and/or using subprocesses).

My other comment in this thread is relevant too: https://news.ycombinator.com/item?id=34197904




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: