Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for What’s New in Python 3.9 alpha2?
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer

Posted on • Originally published atpythonmembers.club

     

What’s New in Python 3.9 alpha2?

Python is set to release a new version next year, the shiny 3.9. This one omitted the sys.argv change rolled back in alpha2 Here’s our take of the most noticeable changes:

Keyword Arguments Get Some Boost

improved

sebastian@seberg-x1 ~/python-dev/bin % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", signed=True)'1000000 loops, best of 5: 205 nsec per loopsebastian@seberg-x1 ~/python-dev/bin % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", signed=True)'1000000 loops, best of 5: 207 nsec per loop

original

sebastian@seberg-x1 ~/python-dev/bin % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", signed=True)'1000000 loops, best of 5: 221 nsec per loopsebastian@seberg-x1 ~/python-dev/bin % ./python3 -m timeit -s 'i = 4' 'i.to_bytes(length=5, byteorder="big", signed=True)'1000000 loops, best of 5: 218 nsec per loop

Audit hooks added forsys.excepthook() andsys.unraisablehook()

Audit hooks were added in PEP 578. It basically allows you to monitor low-level details. It’s aim is to monitor behaviors of Python scripts more accurately. Example of use in the wording of the PEP:

Auditing bypass can occur when the typical system tool used for an action would ordinarily report its use, but accessing the APIs via Python do not trigger this. For example, invoking “curl” to make HTTP requests may be specifically monitored in an audited system, but Python’s “urlretrieve” function is not.

Calling replace on a code object now raises the code.new audit event.
The code object is returned when using the in-built compile() function on some codes. The corresponding C code:

if(PySys_Audit("code.__new__","OOOiiiiii",co_code,co_filename,co_name,co_argcount,co_posonlyargcount,co_kwonlyargcount,co_nlocals,co_stacksize,co_flags)<0){returnNULL;}

Thread stack size set to 8 Mb for debug builds on Android

An initiated script crashes on Android API 24 but only in debug mode. The maximum recursion limit was reduced from 1000 to 100.

In Python you can’t recurse more than some limit.

>>>importsys>>>sys.getrecursionlimit()1000

The above patch was implemented by definingTHREAD_STACK_SIZE to 8mb

define THREAD_STACK_SIZE    0x800000

Added__floor__ and__ceil__ method to float object

Was not previously implemented. Also added tests.

Use ofpython -m pip instead ofpip to upgrade dependencies in venv

In cpython/Lib/venv/init.py alongsize some other changes, the below update setspython -m pip install as default for dependencies upgrade

ifsys.platform=='win32':python_exe=os.path.join(context.bin_path,'python.exe')else:python_exe=os.path.join(context.bin_path,'python')cmd=[python_exe,'-m','pip','install','--upgrade']cmd.extend(CORE_VENV_DEPS)subprocess.check_call(cmd)

Excape key also closes IDLE completion windows

Many keys are used in auto completion. The escape key was just added

KEYPRESS_SEQUENCES=("<Key>","<Key-BackSpace>","<Key-Return>","<Key-Tab>","<Key-Up>","<Key-Down>","<Key-Home>","<Key-End>","<Key-Prior>","<Key-Next>","<Key-Escape>")

That’s was my funnified personal pick!

An originalPythonMembersClub pub.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
wrldwzrd89 profile image
Eric Ahnell
Indie game maker, professional user of Python and C#; programming addict in general.
  • Location
    Ohio
  • Education
    Bachelor's in Computer & Info Science from Cleveland State University
  • Work
    Business Systems Analyst at Rockwell Automation
  • Joined

What I'm curious about is if 3.9 fixes the last of the post-3.3 performance regressions in 3.4+. Python 3.7 improved a ton of these, and 3.8 fixes all but a few. Thanks for the list!

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Cruising python seas. Independent Py Dev
  • Location
    Mauritius
  • Work
    Independent Py Dev at MyOwnAccount
  • Joined

More fromAbdur-Rahmaan Janhangeer

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp