
What’s New in Python 3.7 - happy-go-lucky
https://docs.python.org/3.7/whatsnew/3.7.html
======
Kpourdeilami
Unrelated to python 3.7, but they recently added this feature that you can add
two dictionaries together in 3.5 by doing:

    
    
      new_dict = {**dict1, **dict2}
    

It is so handy and nice

~~~
JupiterMoon
What happens to duplicate keys?

~~~
Kpourdeilami
They get overwritten by the value of the dictionary that came last.

    
    
      >>> dict1 = {"key1": 1, "key2": "hello", "key3": [1, 2, 3]}
      >>> dict2 = {key1": 1, "key2": "world", "key3": [1, 4], "key4": "4"}
    
      >>> {**dict1, **dict2}
      {'key1': 1, 'key2': 'world', 'key3': [1, 4], 'key4': '4'}

~~~
ericfrederich
Lots of code to show that. How 'bout this: ;-)

    
    
      >>> {**{'a': 'first'}, **{'a': 'second'}}
      {'a': 'second'}

------
Twirrim
Some nice optimisations included:

    
    
        Added two new opcodes: LOAD_METHOD and CALL_METHOD to avoid instantiation of bound method objects for method calls, which results in method calls being faster up to 20%. (Contributed by Yury Selivanov and INADA Naoki in bpo-26110.)
        Searching some unlucky Unicode characters (like Ukrainian capital “Є”) in a string was to 25 times slower than searching other characters. Now it is slower only by 3 times in worst case. (Contributed by Serhiy Storchaka in bpo-24821.)
        Fast implementation from standard C library is now used for functions erf() and erfc() in the math module. (Contributed by Serhiy Storchaka in bpo-26121.)
        The os.fwalk() function has been sped up by 2 times. This was done using the os.scandir() function. (Contributed by Serhiy Storchaka in bpo-25996.)
        Optimized case-insensitive matching and searching of regular expressions. Searching some patterns can now be up to 20 times faster. (Contributed by Serhiy Storchaka in bpo-30285.)
        selectors.EpollSelector.modify(), selectors.PollSelector.modify() and selectors.DevpollSelector.modify() may be around 10% faster under heavy loads. (Contributed by Giampaolo Rodola’ in bpo-30014)
    

edit: That one around the unlucky Unicode characters is fascinating.
[https://bugs.python.org/issue24821](https://bugs.python.org/issue24821)

Due to the way that regex searching is optimised, it trips up because: ".. the
lowest byte of the code of Ukrainian capital letter Є (U+0404) matches the
highest byte of codes of most Cyrillic letters (U+04xx). There are similar
issues with some other scripts ..."

------
dorfsmay
"More than 255 arguments can now be passed to a function, and a function can
now have more than 255 parameters."

There are human devs who needed this? Or is this a sign that AI bots are now
involved in language design?

~~~
orf
Perhaps it could trigger if you do function(*iterable), with a huge iterable?

~~~
drizze
I think *iterable would just pass one argument that's a list, not pass each
argument individually

~~~
fiddlerwoaroof

        >>> print([1,2,3])
        [1,2,3]
        >>> print(*[1,2,3])
        1 2 3

~~~
aisofteng
That doesn't tell you anything about when the list is expanded.

------
fulafel
Switching the default encoding from ASCII to utf-8 sounds like a pretty big
change.

~~~
VHRanger
The only real question is:

When am I going to be able to name my variable as emojis?

~~~
dbcurtis
You've been able to do that for a while.

edit: I take that back. Apparently thebunicode allowed in identifers is not
unrestricted..... in my defense I don't use unicode identifiers as a rule....

~~~
masklinn
You can use non-ascii characters but not emoji as arbitrary symbols are not
generally classified as either XID_Start or XID_Continue.

------
CaliforniaKarl
> Support for building --without-threads is removed. (Contributed by Antoine
> Pitrou in bpo-31370.).

Woooo! That means, at some future time, I'll be able to remove code checks for
non-threading Pythons.

~~~
raymondh
This patch was a little aggressive and may get reverted (it caused immediate
code breakage in downstream distros and projects). Changes like this typically
need a deprecation period (that said, to the extent the current feature didn't
really work in the first place, we can immediately take it out).

------
Dowwie
What version will contain dataclasses?

~~~
ericfrederich
What do you mean by this? Do namedtuples not give you this?

    
    
      >>> class MyClass(namedtuple('_MyClass', ['x', 'y', 'z'])):
      ...   def foo(self):
      ...     return self.x * self.y + self.z
      ... 
      >>> x = MyClass(4, 5, 6)
      >>> x.foo()
      26
    

... or an attrs decorated class with frozen=True?

    
    
      >>> import attr
      >>> @attr.s(frozen=True)
      ... class MyClass:
      ...   x = attr.ib()
      ...   y = attr.ib()
      ...   z = attr.ib()
      ...   def foo(self):
      ...     return self.x * self.y + self.z
      ... 
      >>> x = MyClass(4, 5, 6)
      >>> x.foo()
      26

~~~
Dowwie
Close! ericvsmith, gvr, et al were inspired by attrs and have since been
implementing a stdlib version of it, calling it "dataclass"

see:
[https://github.com/ericvsmith/dataclasses](https://github.com/ericvsmith/dataclasses)

and this comment thread is revealing:
[https://github.com/ericvsmith/dataclasses/issues/19](https://github.com/ericvsmith/dataclasses/issues/19)

~~~
ericfrederich
Thanks for that link. Very informative interesting discussion. There must be a
lot of desire for attrs from the stdlib developers.

