Georg Brandl | 10 Feb 23:20 2016
Picon
Picon
Gravatar

PEP 515: Underscores in Numeric Literals

This came up in python-ideas, and has met mostly positive comments,
although the exact syntax rules are up for discussion.

cheers,
Georg

--------------------------------------------------------------------------------

PEP: 515
Title: Underscores in Numeric Literals
Version: $Revision$
Last-Modified: $Date$
Author: Georg Brandl
Status: Draft
Type: Standards Track
Content-Type: text/x-rst
Created: 10-Feb-2016
Python-Version: 3.6

Abstract and Rationale
======================

This PEP proposes to extend Python's syntax so that underscores can be used in
integral and floating-point number literals.

This is a common feature of other modern languages, and can aid readability of
long literals, or literals whose value should clearly separate into parts, such
as bytes or words in hexadecimal notation.

Examples::
(Continue reading)

Luca Sangiacomo | 10 Feb 22:59 2016
Picon

why we have both re.match and re.string?

Hi,
I hope the question is not too silly, but why I would like to understand 
the advantages of having both re.match() and re.search(). Wouldn't be 
more clear to have just one function with one additional parameters like 
this:

re.search(regexp, text, from_beginning=True|False) ?

In this way we prevent, as written in the documentation, people writing 
".*" in front of the regexp used with re.match()

Thanks.
John Mark Vandenberg | 9 Feb 21:00 2016
Picon

Very old git mirror under github user "python-git"

Does anyone know who controls this mirror, which is attracting pull requests?

https://github.com/python-git/python/pulls

Can it be pulled down to avoid confusion, since it is using Python's logo?

https://github.com/python-git

--

-- 
John Vandenberg
Phil Thompson | 9 Feb 12:44 2016

Experiences with Creating PEP 484 Stub Files

I've been adding support to the SIP wrapper generator for automatically generating PEP 484 compatible
stub files so that future versions of PyQt can be shipped with them. By way of feedback I thought I'd share my
experience, confusions and suggestions.

There are a number of things I'd like to express but cannot find a way to do so...

- objects that implement the buffer protocol
- type objects
- slice objects
- capsules
- sequences of fixed size (ie. specified in the same way as Tuple)
- distinguishing between instance and class attributes.

The documentation is incomplete - there is no mention of Set or Tuple for example.

I found the documentation confusing regarding Optional. Intuitively it seems to be the way to specify
arguments with default values. However it is explained in terms of (for example) Union[str, None] and I
(intuitively but incorrectly) read that as meaning "a str or None" as opposed to "a str or nothing".

bytes can be used as shorthand for bytes, bytearray and memoryview - but what about objects that really only
support bytes? Shouldn't the shorthand be called something like AnyBytes?

Is there any recommended way to test the validity and completeness of stub files? What's the recommended
way to parse them?

Phil
Patrascu, Alecsandru | 9 Feb 12:45 2016
Picon

CPython build options for out-of-the box performance

Hi all,

This is Alecsandru from the Dynamic Scripting Languages Optimization Team at Intel Corporation. I want to
open a discussion regarding the way CPython is built, mainly the options that are available to the
programmers. Analyzing the CPython ecosystem we can see that there are a lot of users that just download
the sources and hit the commands "./configure", "make" and "make install" once and then continue using it
with their Python scripts. One of the problems with this workflow it that the users do not benefit from the
entire optimization features that are existing in the build system, such as PGO and LTO.

Therefore, I propose a workflow, like the following. Assume some work has to be done into the CPython
interpreter, a developer can do the following steps:
A. Implementation and debugging phase. 
    1. The command "./configure PYDIST=debug" is ran once. It will enable the Py_DEBUG, -O0 and -g flags
    2. The command "make" is ran once or multiple times

B. Testing the implementation from step A, in a pre-release environment
    1. The command "./configure PYDIST=devel" is ran once. It will disable the Py_DEBUG flags and will enable
the -O3 and -g flags, and it is just like the current implementation in CPython
    2. The command "make" is ran once or multiple times

C. For any other CPython usage, for example distributing the interpreter, installing it inside an
operating system, or just the majority of users who are not CPython developers and only want to compile it
once and use it as-is:
    1. The command "./configure" is ran once. Alternatively, the command  "./configure PYDIST=release" can
be used. It will disable all debugging functionality, enable the -O3 flag and will enable PGO and LTO.
    2. The command "make" is ran once

If you think this benefits CPython, I can create an issue and post the patches that enable all of the above. 

Thank you,
(Continue reading)

Stephane Wirtel | 8 Feb 19:34 2016
Picon
Gravatar

Syntax Highlightning for C API of CPython in VIM

Hi everyone,

With my talk "Exploring our Python Interpreter", I think this VIM plugin 
can be useful for the community. It's a syntax highlighter for the C API 
of CPython 3.5 and 3.6. I used Clang for the parsing and automatically 
generated the keywords for VIM.

PyObject and the others typedefs of CPython will have the defined color 
of your favourite editor and it's the same for the enums, the typedefs, 
the functions and the macros.

Where can you use this VIM plugin ? If you want to write a CPython 
extension or if you want to hack in the CPython code.

Check this screenshot: http://i.imgur.com/0k13KOU.png

Here is the repository:

https://github.com/matrixise/cpython-vim-syntax

Please, if you see some issues, tell me via an issue on Github.

Thank you so much,

Stephane

--

-- 
St├ęphane Wirtel - http://wirtel.be -  <at> matrixise
_______________________________________________
Python-Dev mailing list
(Continue reading)

Victor Stinner | 8 Feb 18:44 2016
Picon
Gravatar

Issue #26204: compiler now emits a SyntaxWarning on constant statement

Hi,

I changed the Python compiler to ignore any kind "constant
expressions", whereas it only ignored strings and integers before:
http://bugs.python.org/issue26204

The compiler now also emits a SyntaxWarning on such case. IMHO the
warning can help to detect bugs for developers who just learnt Python.

The warning is *not* emited for strings, since triple quoted strings
are a common syntax for multiline comments.

The warning is *not* emited neither for ellispis (...) since "f():
..." is a legit syntax for abstract function.

Are you ok with the new warning?

New behaviour:

haypo <at> smithers$ ./python
Python 3.6.0a0 (default:759a975e1230, Feb  8 2016, 18:21:23)
>>> def f():
...  False
...
<stdin>:2: SyntaxWarning: ignore constant statement

>>> import dis; dis.dis(f)
  2           0 LOAD_CONST               0 (None)
              3 RETURN_VALUE

(Continue reading)

Kevin Hong | 8 Feb 18:19 2016

HackIllinois 2016 + Python

Hi all!

My name is Kevin and I am a staff member of HackIllinois, a 36-hour hackathon at the University of Illinois Urbana-Champaign where students from across the nation come to build some of the most innovative hardware and software projects. For highlights from last year’s event, check outgo.hackillinois.org/video.

From February 19-21st 2016, HackIllinois returns and we are introducing a new initiative called OpenSource <at> HackIllinois to promote Open Source development during the event. This program is designed to provide students with the opportunity to meet and collaborate with experienced developers, like you all, who serve as a guide and mentor into the open source world. Over the course of the event, you and your group of hackers will build features for an open source project of your choosing. Please see http://www.hackillinois.org/opensource for more details!

If you or any other open source developers you work with are interested in learning more about OpenSource <at> HackIllinois, feel free to email me at kevin.hong <at> hackillinois.org. I look forward to speaking with you soon!

Best Regards,

Kevin Hong


<div><div dir="ltr">Hi all!<div>
<p dir="ltr">My name is Kevin and I am a staff member of HackIllinois, a 36-hour hackathon at the University of Illinois Urbana-Champaign where students from across the nation come to build some of the most innovative hardware and software projects. For highlights from last year&rsquo;s event, check out<a href="http://go.hackillinois.org/video" target="_blank">go.hackillinois.org/video</a>.<br></p>
<p dir="ltr">From February 19-21st 2016, HackIllinois returns and we are introducing a new initiative called OpenSource <at> HackIllinois to promote Open Source development during the event. This program is designed to provide students with the opportunity to meet and collaborate with experienced developers, like you all, who serve as a guide and mentor into the open source world. Over the course of the event, you and your group of hackers will build features for an open source project of your choosing. Please see&nbsp;<a href="http://www.hackillinois.org/opensource" target="_blank">http://www.hackillinois.org/opensource</a>&nbsp;for more details!</p>
<p dir="ltr">If you or any other open source developers you work with are interested in learning more about OpenSource <at> HackIllinois, feel free to email me at <a href="mailto:kevin.hong <at> hackillinois.org" target="_blank">kevin.hong <at> hackillinois.org</a>. I look forward to speaking with you soon!</p>
<p dir="ltr">Best Regards,</p>
<p dir="ltr">Kevin Hong</p>
</div>
<div><br></div>
</div></div>
Ben Hoyt | 8 Feb 17:23 2016
Picon
Gravatar

Improving docs for len() of set

Hi folks,

Just a suggestion for a documentation tweak. Currently the docs for len() on a set say this:

   .. describe:: len(s)

      Return the cardinality of set *s*.

I'm a relatively seasoned programmer, but I don't really have a maths background, and I didn't know what "cardinality" meant. I could kind of grok it by context, but could we change this to something like the following?

   .. describe:: len(s)

      Return the number of elements in set *s* (cardinality of *s*).

Happy to open a bugs.python.org issue on this, but wanted to get general consensus first.

-Ben

<div><div dir="ltr">
<div>
<div>Hi folks,</div>
<div><br></div>
<div>Just a suggestion for a documentation tweak. Currently the docs for len() on a set say this:</div>
<div><br></div>
<div>&nbsp; &nbsp;.. describe:: len(s)</div>
<div><br></div>
<div>&nbsp; &nbsp; &nbsp; Return the cardinality of set *s*.</div>
<div><br></div>
<div>I'm a relatively seasoned programmer, but I don't really have a maths background, and I didn't know what "cardinality" meant. I could kind of grok it by context, but could we change this to something like the following?</div>
<div><br></div>
<div>&nbsp; &nbsp;.. describe:: len(s)</div>
<div><br></div>
<div>&nbsp; &nbsp; &nbsp; Return the number of elements in set *s* (cardinality of *s*).</div>
<div><br></div>
<div>Happy to open a <a href="http://bugs.python.org">bugs.python.org</a> issue on this, but wanted to get general consensus first.</div>
<div><br></div>
<div>-Ben</div>
</div>
<div><br></div>
</div></div>
Victor Stinner | 8 Feb 15:32 2016
Picon
Gravatar

Windows: Remove support of bytes filenames in the os module?

Hi,

Since 3.3, functions of the os module started to emit
DeprecationWarning when called with bytes filenames.

The rationale is quite simple: Windows native type for filenames is
Unicode, and the Windows has a weird behaviour when you use bytes. For
example, os.listdir(b'.') gives you paths which cannot be used with
open() on filenames which are not encodable the ANSI code page.
Unencodable characters are replaced with "?". The following issue was
opened to document this weird behaviour (but the doc was never
completed):

"Document that bytes OS API can returns unusable results on Windows"
http://bugs.python.org/issue16700

When the new os.scandir() API was designed, I asked to *not* support
bytes filenames since they are "broken by design".
https://www.python.org/dev/peps/pep-0471/

Recently, an user complained that os.walk() doesn't work with bytes on
Windows anymore:

"Regression: os.walk now using os.scandir() breaks bytes filenames on windows"
http://bugs.python.org/issue25911

Serhiy Storchaka just pushed a change to reintroduce support bytes
support on Windows in os.walk(), but I would prefer to do the
*opposite*: drop supports for bytes filenames on Windows.

Are we brave enough to force users to use the "right" type for filenames?

--

On Python 2, it wasn't possible to use Unicode for filenames, many
functions fail badly with Unicode, especially when you mix bytes and
Unicode.

On Python 3, Unicode is the "natural" types, most Python functions
prefer Unicode, and the PEP 383 (surrogateescape) allows to safetely
use Unicode on UNIX even with undecodable filenames (invalid bytes are
stored as Unicode surrogate characters).

Victor
Randy Eels | 7 Feb 14:58 2016
Picon

When does `PyType_Type.tp_alloc get assigned to PyType_GenericAlloc ?

Hi everyone,

I've a question about the implementation of the `type` builtin (in Python 3.5).

In Objects/typeobject.c, the `tp_alloc` slot of PyType_Type gets set to 0. However, I can see (using gdb) that it later gets assigned to `&PyType_GenericAlloc`. I'd argue that this makes sense because, in `type_new`, there is a line where that member function gets called without previously checking whether that member points to something:

```
    /* Allocate the type object */
    type = (PyTypeObject *)metatype->tp_alloc(metatype, nslots);
```

Yet, I can't seem to understand where and when does the `tp_alloc` slot of PyType_Type get re-assigned to PyType_GenericAlloc. Does that even happen? Or am I missing something bigger?

And, just out of further curiosity, why doesn't the aforementioned slot get initialised to `PyType_GenericAlloc` in the first place?

Thanks a lot.
<div><div dir="ltr">Hi everyone,<div><br></div>
<div>I've a question about the implementation of the `type` builtin (in Python 3.5).</div>
<div><br></div>
<div>In Objects/typeobject.c, the `tp_alloc` slot of PyType_Type gets set to 0. However, I can see (using gdb) that it later gets assigned to `&amp;PyType_GenericAlloc`. I'd argue that this makes sense because, in `type_new`, there is a line where that member function gets called without previously checking whether that member points to something:</div>
<div><br></div>
<div>```</div>
<div>
<div>&nbsp; &nbsp; /* Allocate the type object */</div>
<div>&nbsp; &nbsp; type = (PyTypeObject *)metatype-&gt;tp_alloc(metatype, nslots);</div>
</div>
<div>```</div>
<div><br></div>
<div>Yet, I can't seem to understand where and when does the `tp_alloc` slot of PyType_Type get re-assigned to&nbsp;PyType_GenericAlloc. Does that even happen? Or am I missing something bigger?</div>
<div><br></div>
<div>And, just out of further curiosity, why doesn't the aforementioned slot get initialised to `PyType_GenericAlloc` in the first place?</div>
<div><br></div>
<div>Thanks a lot.</div>
</div></div>

Gmane