Live data from Hacker News

What's Coming in Python 3.8

lwn.net

421–430 of 558 posts

Re: What's Coming in Python 3.8

#421

To me, the headline feature for Python 3.8 is shared memory for multiprocessing (contributed by Davin Potts). Some kinds of data can be passed back and forth between processes with near zero overhead (no pickling, sockets, or unpickling). This significantly improves Python's story for taking advantage of multiple cores.

> no pickling, sockets, or unpickling

But still copying?

If not, then how does it interoperate with garbage collection?

Re: What's Coming in Python 3.8

#422

To me, the headline feature for Python 3.8 is shared memory for multiprocessing (contributed by Davin Potts). Some kinds of data can be passed back and forth between processes with near zero overhead (no pickling, sockets, or unpickling). This significantly improves Python's story for taking advantage of multiple cores.

I’ve been waiting for this for a very long time. Thank you for mentioning this. Would this work with e.g. large NumPy arrays? (and this is Raymond Hettinger himself, wow)

An alternative you may want is Dask.

Re: What's Coming in Python 3.8

#423
post #152

Earlier quoted context omitted.

Does that mean someone born in 2008 will think C++ is simple and elegant?

I am both a Python programmer and a C++ programmer. I have programmed professionally full time in one or the other for years at a time. I think C++ is now a much better language than when I learnt it first (cfront). In particular C++11 really fixed a lot of the memory issues with shared_ptr and std:: algorithms. It is a better language now if you are doing anything larger than then a program that takes more than a fe…

C++ might be "better" now (I doubt it, to be honest, it just has more features that try to fix the issue at hand; that you're using C++), but it will never, ever get simpler or simple enough. They'd have to remove something like 75% of the language to end up with something that approaches simplicity and even then there are languages that would undoubtedly do those remaining 25% much better.

I stopped writing C++ at some point in 2008/2009 but I still keep track of it to some extent and I'm continually surprised by the nonsense that is introduced into the language. The whole RAII movement, for example, is just one massive band-aid on top of the previous mistake of allowing exceptions, etc..

It'd be mostly fine in the long run, but you have all these people using like 15% of C++ and complain about it all day long, making their libraries not usable from stuff that understands C (most of which have drastically improved on the whole paradigm). There's a solution here and it's not using whichever arbitrary percentage you've decided on of C++, it's realizing that there are way better languages with real interoperability in mind to talk about lower-level things.

Re: What's Coming in Python 3.8

#424

To me, the headline feature for Python 3.8 is shared memory for multiprocessing (contributed by Davin Potts). Some kinds of data can be passed back and forth between processes with near zero overhead (no pickling, sockets, or unpickling). This significantly improves Python's story for taking advantage of multiple cores.

Agreed this is huge.

Re: What's Coming in Python 3.8

#425
post #62

Earlier quoted context omitted.

But now there are two ways to do assignment. That's not very pythonic, is it?

I see this criticism every time the walrus operator is brought up. You do know that this: x := 1 Is going to be a syntax error, right? The walrus operator is not permitted in the case of a simple assignment statement. It's only in an expression.

But it used to be that any expression on its own was a valid statement. Is that going to change?

When is an expression allowed to have := in it, is

  (x := 1)
on its own allowed?

Re: What's Coming in Python 3.8

#426

Earlier quoted context omitted.

By itself I agree, every now and then you write a few lines that will be made a little shorter now that := exists. But there's a long standing trend of adding more and more of these small features to what was quite a clean and small language. It's becoming more complicated, backwards compatibility suffers, the likelyhood your coworker uses some construct that you never use increases, there is more to know about Pytho…

they should pick f and put depreciation warnings on the other two, python is getting messy.

They can’t just deprecate the other two; f-string’s nature precludes it from being used in situations where formatting needs to occur lazily, e.g. i18n. This is the same reason why other languages with string interpolation also keep a format method around, e.g. Swift’s String(format:). I guess you could argue that they should at least deprecate %-formatting, and this has indeed been raised multiple times, even prior to f-string’s introduction, but the power of Backwards Compatibility Gods are still strong there, for better or for worse.

Re: What's Coming in Python 3.8

#427
post #381

That walrus operator has given me exactly what I wanted from C. Although I'd have preferred: if val = expr():

That particular version opens the way for massive typo footguns and results in the insanity of defensive programming patterns like yoda expressions.

Well, for those used to those expressions, it definitely helps write that code with one line lesser (assignment by itself).

Most likely, the assigned value is stored for use in one of the conditionals, so it really doesn't change any of that.

Let's also understand that we are dealing with a decorated assignment here, so a = (b = c) should be no different from evaluating (b = c). It's not complicated, the way I at least look at it.

Re: What's Coming in Python 3.8

#428

Earlier quoted context omitted.

One of the good things about not using the "=" operator is that you cannot accidentally turn a comparison into an assignment, a feature that is a common cause of errors in other languages that do support it. By adding a completely different character to the operator it is not very likely to cause bugs, compared to just forgetting to type that second =

Is it really that common? I made this typo a few times in my life. It was corrected every time before the program actually run because the compiler warned me about it. I don't see how you can make this mistake if you're not aggressively trying (by turning off warnings for example).

I guess it is not common, but by using the = operator you would not get the warning, and instead get unexpected behaviour.

Re: What's Coming in Python 3.8

#429

Earlier quoted context omitted.

Here's a clean way to do that: str_fmt = "File exists, not uploading: {filename} -> {bucket}, {key}" fmt_vals = dict(filename=filename, bucket=bucket, key=key) raise ValueError(str_fmt.dedent().format(**fmt_vals))

This is somewhat cleaner, and I also use this idiom when things get ugly with the inline formatting shown above. But my point is that none of these are very elegant for an extremely common use case. Throw this block in the middle of some complex code with a few try/except and raise statements and it still looks confusing. Having two extra temp variables and statements per error in a function that's just doing control…

[deleted]
Post reply on HN