Argument Clinic "converters" specify how to convert an individual
argument to the function you're defining. Although a converter could
theoretically represent any sort of conversion, most of the time they
directly represent types like "int" or "double" or "str".
Because there's such variety in argument parsing, the converters are
customizable with parameters. Many of these are common enough that
Argument Clinic suggests some standard names. Examples: "zeroes=True"
for strings and buffers means "permit internal \0 characters", and
"bitwise=True" for unsigned integers means "copy the bits over, even if
there's overflow/underflow, and even if the original is negative".
A third example is "nullable=True", which means "also accept None for
this parameter". This was originally intended for use with strings
(compare the "s" and "z" format units for PyArg_ParseTuple), however it
looks like we'll have a use for "nullable ints" in the ongoing Argument
Clinic conversion work.
Several people have said they found the name "nullable" surprising,
suggesting I use another name like "allow_none" or "noneable". I, in
turn, find their surprise surprising; "nullable" is a term long
associated with exactly this concept. It's used in C# and SQL, and the
term even has its own Wikipedia page:
http://en.wikipedia.org/wiki/Nullable_type
Most amusingly, Vala *used* to have an annotation called "(allow-none)",
but they've broken it out into two annotations, "(nullable)" and
"(optional)".
http://blogs.gnome.org/desrt/2014/05/27/allow-none-is-dead-long-live-nullab…
Before you say "the term 'nullable' will confuse end users", let me
remind you: this is not user-facing. This is a parameter for an
Argument Clinic converter, and will only ever be seen by CPython core
developers. A group which I hope is not so easily confused.
It's my contention that "nullable" is the correct name. But I've been
asked to bring up the topic for discussion, to see if a consensus forms
around this or around some other name.
Let the bike-shedding begin,
//arry/
Here is some proposed wording. Since it is more of a clarification of what
it takes to garner support -- which is just a new section -- rather than a
complete rewrite I'm including just the diff to make it easier to read the
changes.
*diff -r 49d18bb47ebc pep-0011.txt*
*--- a/pep-0011.txt Wed May 14 11:18:22 2014 -0400*
*+++ b/pep-0011.txt Fri May 16 13:48:30 2014 -0400*
@@ -2,22 +2,21 @@
Title: Removing support for little used platforms
Version: $Revision$
Last-Modified: $Date$
-Author: martin(a)v.loewis.de (Martin von Löwis)
+Author: Martin von Löwis <martin(a)v.loewis.de>,
+ Brett Cannon <brett(a)python.org>
Status: Active
Type: Process
Content-Type: text/x-rst
Created: 07-Jul-2002
Post-History: 18-Aug-2007
+ 16-May-2014
Abstract
--------
-This PEP documents operating systems (platforms) which are not
-supported in Python anymore. For some of these systems,
-supporting code might be still part of Python, but will be removed
-in a future release - unless somebody steps forward as a volunteer
-to maintain this code.
+This PEP documents how an operating system (platform) garners
+support in Python as well as documenting past support.
Rationale
@@ -37,16 +36,53 @@
change to the Python source code will work on all supported
platforms.
-To reduce this risk, this PEP proposes a procedure to remove code
-for platforms with no Python users.
+To reduce this risk, this PEP specifies what is required for a
+platform to be considered supported by Python as well as providing a
+procedure to remove code for platforms with little or no Python
+users.
+Supporting platforms
+--------------------
+
+Gaining official platform support requires two things. First, a core
+developer needs to volunteer to maintain platform-specific code. This
+core developer can either already be a member of the Python
+development team or be given contributor rights on the basis of
+maintaining platform support (it is at the discretion of the Python
+development team to decide if a person is ready to have such rights
+even if it is just for supporting a specific platform).
+
+Second, a stable buildbot must be provided [2]_. This guarantees that
+platform support will not be accidentally broken by a Python core
+developer who does not have personal access to the platform. For a
+buildbot to be considered stable it requires that the machine be
+reliably up and functioning (but it is up to the Python core
+developers to decide whether to promote a buildbot to being
+considered stable).
+
+This policy does not disqualify supporting other platforms
+indirectly. Patches which are not platform-specific but still done to
+add platform support will be considered for inclusion. For example,
+if platform-independent changes were necessary in the configure
+script which was motivated to support a specific platform that would
+be accepted. Patches which add platform-specific code such as the
+name of a specific platform to the configure script will generally
+not be accepted without the platform having official support.
+
+CPU architecture and compiler support are viewed in a similar manner
+as platforms. For example, to consider the ARM architecture supported
+a buildbot running on ARM would be required along with support from
+the Python development team. In general it is not required to have
+a CPU architecture run under every possible platform in order to be
+considered supported.
Unsupporting platforms
----------------------
-If a certain platform that currently has special code in it is
-deemed to be without Python users, a note must be posted in this
-PEP that this platform is no longer actively supported. This
+If a certain platform that currently has special code in Python is
+deemed to be without Python users or lacks proper support from the
+Python development team and/or a buildbot, a note must be posted in
+this PEP that this platform is no longer actively supported. This
note must include:
- the name of the system
@@ -69,8 +105,8 @@
forward and offer maintenance.
-Resupporting platforms
-----------------------
+Re-supporting platforms
+-----------------------
If a user of a platform wants to see this platform supported
again, he may volunteer to maintain the platform support. Such an
@@ -101,7 +137,7 @@
release is made. Developers of extension modules will generally need
to use the same Visual Studio release; they are concerned both with
the availability of the versions they need to use, and with keeping
-the zoo of versions small. The Python source tree will keep
+the zoo of versions small. The Python source tree will keep
unmaintained build files for older Visual Studio releases, for which
patches will be accepted. Such build files will be removed from the
source tree 3 years after the extended support for the compiler has
@@ -223,6 +259,7 @@
----------
.. [1] http://support.microsoft.com/lifecycle/
+.. [2] http://buildbot.python.org/3.x.stable/
Copyright
---------
The current memory layout for dictionaries is
unnecessarily inefficient. It has a sparse table of
24-byte entries containing the hash value, key pointer,
and value pointer.
Instead, the 24-byte entries should be stored in a
dense table referenced by a sparse table of indices.
For example, the dictionary:
d = {'timmy': 'red', 'barry': 'green', 'guido': 'blue'}
is currently stored as:
entries = [['--', '--', '--'],
[-8522787127447073495, 'barry', 'green'],
['--', '--', '--'],
['--', '--', '--'],
['--', '--', '--'],
[-9092791511155847987, 'timmy', 'red'],
['--', '--', '--'],
[-6480567542315338377, 'guido', 'blue']]
Instead, the data should be organized as follows:
indices = [None, 1, None, None, None, 0, None, 2]
entries = [[-9092791511155847987, 'timmy', 'red'],
[-8522787127447073495, 'barry', 'green'],
[-6480567542315338377, 'guido', 'blue']]
Only the data layout needs to change. The hash table
algorithms would stay the same. All of the current
optimizations would be kept, including key-sharing
dicts and custom lookup functions for string-only
dicts. There is no change to the hash functions, the
table search order, or collision statistics.
The memory savings are significant (from 30% to 95%
compression depending on the how full the table is).
Small dicts (size 0, 1, or 2) get the most benefit.
For a sparse table of size t with n entries, the sizes are:
curr_size = 24 * t
new_size = 24 * n + sizeof(index) * t
In the above timmy/barry/guido example, the current
size is 192 bytes (eight 24-byte entries) and the new
size is 80 bytes (three 24-byte entries plus eight
1-byte indices). That gives 58% compression.
Note, the sizeof(index) can be as small as a single
byte for small dicts, two bytes for bigger dicts and
up to sizeof(Py_ssize_t) for huge dict.
In addition to space savings, the new memory layout
makes iteration faster. Currently, keys(), values, and
items() loop over the sparse table, skipping-over free
slots in the hash table. Now, keys/values/items can
loop directly over the dense table, using fewer memory
accesses.
Another benefit is that resizing is faster and
touches fewer pieces of memory. Currently, every
hash/key/value entry is moved or copied during a
resize. In the new layout, only the indices are
updated. For the most part, the hash/key/value entries
never move (except for an occasional swap to fill a
hole left by a deletion).
With the reduced memory footprint, we can also expect
better cache utilization.
For those wanting to experiment with the design,
there is a pure Python proof-of-concept here:
http://code.activestate.com/recipes/578375
YMMV: Keep in mind that the above size statics assume a
build with 64-bit Py_ssize_t and 64-bit pointers. The
space savings percentages are a bit different on other
builds. Also, note that in many applications, the size
of the data dominates the size of the container (i.e.
the weight of a bucket of water is mostly the water,
not the bucket).
Raymond
Hi all,
https://github.com/python/cpython is now live as a semi-official, *read
only* Github mirror of the CPython Mercurial repository. Let me know if you
have any problems/concerns.
I still haven't decided how often to update it (considering either just N
times a day, or maybe use a Hg hook for batching). Suggestions are welcome.
The methodology I used to create it is via hg-fast-export. I also tried to
pack and gc the git repo as much as possible before the initial Github push
- it went down from almost ~2GB to ~200MB (so this is the size of a fresh
clone right now).
Eli
P.S. thanks Jesse for the keys to https://github.com/python
Hi all,
I've just updated the PEP to reflect the API suggestions from Nick, and the
fact that the necessary changes to urllib were landed.
I think this is ready for pronouncement, Guido?
Cheers,
Alex
Hi,
I'm using Python buildbots to ensure that my changes don't fail on
some platform. It's important for changes close to the operation
system. The problem is that many buildbots are ill.
Before, only a few buildbots had sporadic failures. Now most buildbots
are always fail (are red).
Here is an incomplete list of failures seen on buildbots. Before I
opened an issue for each bug, but usually nobody takes care of them.
So today I'm trying the mailing list.
How can we fix all these issues to have more "green" buildbots? Can
anyone help on this task?
AMD64 OpenIndiana 3.x: a lot of tests fail with OSError(12, "Not
enough space") or MemoryError. It's probably on issue on the host.
AMD64 Snow Leop 3.x: many tests are not reliable (stable) on this
platform. For example, test_logging.test_race() sometimes fail with
PermissionError(1, "Operation not permitted:
'/tmp/test_logging-3-bjulw8iz.log'"). Another example,
test_asyncio.test_stdin_broken_pipe() sometimes fail with an assertion
error because BrokenPipeError was not raised. Do we still support this
old version of Mac OS X? Released in 2009, it is 5 years old. Is
upgrading to Maverick (10.9) free and possible on old Mac computers? I
don't have access to this old OS.
x86 RHEL 6 3.x: TestReadline.test_init() fails, issue #19884. I don't
have to this platform, I don't know how to fix it.
x86 Windows Server 2003 [SB] 3.x: test_build_ext() of test_distutils
hangs during 1 hang before being killed, it hangs something in the C
compiler.
x86 Windows7 3.x: test_nntplib fails with OSError("cannot read from
timed out object").
x86 XP-4 3.x: test_distutils fails because Visual Studio linker
(link.exe) fails with the error 1181 (cannot open input file).
test_capi.test_forced_io_encoding() fails with an assertion error
because sys.__stdin__ is None.
AMD64 Solaris 11 [SB] 3.x: sometimes, tests fail with MemoryError.
test_uuid.test_uuid4() fails with an assertion error. ctypes has issue
with the sign of integer numbers (bug in libffi?).
ARMv7 3.x: "Read-only file system", Mercurial fails...
x86 FreeBSD 7.2 3.x: test_io.test_interrupted_write_text() hangs.
x86 FreeBSD 6.4 3.x: test_urllib2net.test_urlwithfrag() fails with
urllib.error.URLError: <urlopen error unknown url type: https>.
test_tcl has many issues. test_multiprocessing_spawn fails whereas the
test should be skipped.
x86 OpenBSD 5.5 3.x: many failing tests.
x86 OpenIndiana 3.x: MemoryError. TestReadline.test_init() also fails.
x86 Tiger 3.x: test_nntplib fails with OSError("cannot read from timed
out object".
I skipped "SPARC Solaris 10 OpenCSW 3.x" and "PPC64 AIX 3.x" in my
list, I'm not really interested by these platforms.
Victor
Hi all,
(This is advance notice since people on this list will be interested. Official announcements are coming when setuptools makes their next release.)
Microsoft has released a compiler package targeting Python 2.7 (i.e. VC9). We've produced this package to help library developers build wheels for Windows, but also to help users unblock themselves when they need to build C extensions themselves.
The Microsoft Visual C++ Compiler for Python 2.7 is available from: http://aka.ms/vcpython27
This package contains all the tools and headers required to build C extension modules for Python 2.7 32-bit and 64-bit (note that some extension modules require 3rd party dependencies such as OpenSSL or libxml2 that are not included). Other versions of Python built with Visual C++ 2008 are also supported.
You can install the package without requiring administrative privileges and, with the latest version of setuptools (when it releases), use tools such as pip, wheel, or a setup.py file to produce binaries on Windows.
Unfortunately, this package isn't necessarily going to help with building CPython 2.7 itself, as the build process is complicated and Visual Studio 2008 is practically required. However, as most people aren't building CPython on Windows, this isn't a huge issue. This compiler package should be sufficient for most extension modules.
I should also point out that VC9 is no longer supported by Microsoft. This means there won't be any improvements or bug fixes coming, and there's no official support offered. Feel free to contact me directly <steve.dower(a)microsoft.com> if there are issues with the package.
Cheers,
Steve
Hi,
as Fedora is getting closer to having python3 as a default, I'm being more and more asked by Fedora users/contributors what'll "/usr/bin/python" invoke when we achieve this (Fedora 22 hopefully). So I was rereading PEP 394 and I think I need a small clarification regarding two points in the PEP:
- "for the time being, all distributions should ensure that python refers to the same target as python2."
- "Similarly, the more general python command should be installed whenever any version of Python is installed and should invoke the same version of Python as either python2 or python3."
The important word in the second point is, I think, *whenever*. Trying to apply these two points to Fedora 22 situation, I can think of several approaches:
- /usr/bin/python will always point to python3 (seems to go against the first mentioned PEP recommendation)
- /usr/bin/python will always point to python2 (seems to go against the second mentioned PEP recommendation, there is no /usr/bin/python if python2 is not installed)
- /usr/bin/python will point to python3 if python2 is not installed, else it will point to python2 (inconsistent; also the user doesn't know he's running and what libraries he'll be able to import - the system can have different sets of python2-* and python3-* extension modules installed)
- there will be no /usr/bin/python (goes against PEP and seems just wrong)
I'd really appreciate upstream guidance and perhaps a PEP clarification for distributions that ship both python2 and python3, but can live without python2 (and are not Arch :)).
Thanks a lot!
--
Regards,
Slavek Kabrda
On 09/24/2014 10:00 PM, Nick Coghlan <ncoghlan(a)gmail.com> wrote:
> Subject: Re: [Python-Dev] 3.5 release schedule PEP
>
> On 24 Sep 2014 15:15, "Tim Golden" <mail(a)timgolden.me.uk> wrote:
> >
> > On 23/09/2014 18:05, Steve Dower wrote:
> >> I'm also considering/experimenting with installing into "Program
> >> Files" by default, but I suspect that isn't going to work out yet.
> >
> > I'd like to see that go forward: I think it's increasingly difficult to
> justify Python's position at c:\pythonxx. But it does run the risk of
> > breaking All The Things.
>
> It might be better to offer that as a supported option in 3.5, and then make it
> the default in 3.6.
>
> That will offer a couple of years to work out the issues, rather than a few months.
Hi all,
ProgramFiles was the default in Python 1.X.
It has been a supported option for just shy of 15 years on 2.X... most if not
all the bugs (setuptools) were fixed a decade ago, and right now thousands, if
not millions of people are running it under Program Files right now. I can
vouch for several thousand because a company I work for distributes Python and
pip there for its customers all around the world w/o issue.
I've never once encountered a bug due to install to ProgramFiles, or heard of
anyone who has, and have been using Python for everything since the year 2000.
If any rare bugs happen to surface, they can likely be fixed or replaced with a
line of code, or worked around by installing elsewhere.
The potential existence of such bugs isn't enough reason to stay stuck in 1990
while leaving users vulnerable to tampering attacks for another few years.
-Mike