Python Asynchronous Comprehensions – how do they work?

You are basically asking how an async for loop works over a regular loop. That you can now use such a loop in a list comprehension doesn’t make any difference here; that’s just an optimisation that avoids repeated list.append() calls, exactly like a normal list comprehension does. An async for loop then, simply awaits each … Read more

Documenting class attributes with type annotations

I do not think you can put an Attribute section inside of your docstring to get your desired results. I tried giving each attribute a doc comment and specified the type and desired comment. class DataHolder: “”” Class to hold some data Each attribute needs its own doc comment with its type “”” #: bool: … Read more

iter() not working with datetime.now()

This is definitely a bug introduced in Python 3.6.0b1. The iter() implementation recently switched to using _PyObject_FastCall() (an optimisation, see issue 27128), and it must be this call that is breaking this. The same issue arrises with other C classmethod methods backed by Argument Clinic parsing: >>> from asyncio import Task >>> Task.all_tasks() set() >>> … Read more

Why were literal formatted strings (f-strings) so slow in Python 3.6 alpha? (now fixed in 3.6 stable)

Note: This answer was written for the Python 3.6 alpha releases. A new opcode added to 3.6.0b1 improved f-string performance significantly. The f”…” syntax is effectively converted to a str.join() operation on the literal string parts around the {…} expressions, and the results of the expressions themselves passed through the object.__format__() method (passing any :.. … Read more

pip3 installs inside virtual environment with python3.6 failing due to ssl module not available

I followed the below steps for python3.6 installation in ubuntu 14.04 and virtualenv pip installs works fine. Python 3.6 Installation: sudo apt-get install python3-dev libffi-dev libssl-dev wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz tar xvf Python-3.6.0.tgz cd Python-3.6.0 ./configure –enable-optimizations make -j8 sudo make altinstall python3.6 If seeing the following error — zipimport.ZipImportError: can’t decompress data; zlib not available make: … Read more

Microsoft Windows Python-3.6 PyCrypto installation error

The file include\pyport.h in Python installation directory does not have #include < stdint.h > anymore. This leaves intmax_t undefined. A workaround for Microsoft VC compiler is to force include stdint.h via OS environment variable CL: Open command prompt Setup VC environment by runing vcvars*.bat (choose file name depending on VC version and architecture) set CL=-FI”Full-Path\stdint.h” … Read more

Why can’t I ‘yield from’ inside an async function?

According to PEP 525, which introduces asyncronous generators in Python 3.6: Asynchronous yield from While it is theoretically possible to implement yield from support for asynchronous generators, it would require a serious redesign of the generators implementation. yield from is also less critical for asynchronous generators, since there is no need provide a mechanism of … Read more