[Python-ideas] RFC: PEP xxx: Python Compatibility Version

2019-10-17 Thread Victor Stinner
oming end of Python 2 support, it's the right time to propose this PEP! Victor PEP: xxx Title: Python Compatibility Version Author: Victor Stinner Status: Draft Type: Standards Track Content-Type: text/x-rst Created: 18-Oct-2019 Python-Version: 3.9 Abstract ===

[Python-ideas] Re: RFC: PEP xxx: Python Compatibility Version

2019-10-18 Thread Victor Stinner
Hi Ethan, Le ven. 18 oct. 2019 à 04:38, Ethan Furman a écrit : > > To remain relevant and useful, Python has to evolve frequently. Some > > enhancements require incompatible changes. Any incompatible change can > > break an unknown number of Python projects. Developers can decide to > > not impl

[Python-ideas] Re: Expose Py_TabcheckFlag as other PyAPI_DATA flag.

2019-10-21 Thread Victor Stinner
Eloi opened https://bugs.python.org/issue38543 This issue is specific to Python 2.7. Python 3 no longer has Py_TabcheckFlag. Eloi: hey, you should upgrade to Python 3 and have a look at my PEP 587 "Python Initialization Configuration" ;-) Victor ___ Py

[Python-ideas] Re: Expose _PyGC_generation0 for allowing internal use directly from a CPython extension

2019-10-21 Thread Victor Stinner
He opened https://bugs.python.org/issue38542 It seems like the issue is specific to Python 2.7. Well, see the issue for more details ;-) Victor ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-le...@p

[Python-ideas] Re: Resetting peak memory metric in tracemalloc without touching other traces

2020-05-14 Thread Victor Stinner
Hi, The following function is completely reasonable. It shouldn't be hard to implement it (a few lines of C code). def reset_peak_memory(): # in _tracemalloc.c tracemalloc_peak_trace_memory = tracemalloc_traced_memory; Reset the peak to tracemalloc_traced_memory is correct :-

Re: [Python-ideas] Force UTF-8 option regardless locale

2016-08-30 Thread Victor Stinner
Le 30 août 2016 02:05, "INADA Naoki" a écrit : > How should the option be set? I propose to add a new -X utf8 option. Maybe if the use case is important, we might add an PYTHONUTF8 environment variable. The problem is that I'm not sure that an env var is the right way to configure Python on such

Re: [Python-ideas] Changing optimisation level from a script

2016-09-10 Thread Victor Stinner
2016-09-10 2:56 GMT-04:00 Andrew Svetlov : > There are also peephole optimization. > Removing it may prevent false positives for coverage tool > http://bugs.python.org/issue2506 My PEP 511 adds "-o noopt" to disable the peephole optimizer ;-) "PEP 511 -- API for code transformers" www.python.org/

Re: [Python-ideas] Flagging blocking functions not to be used with asyncio

2016-10-08 Thread Victor Stinner
It seems different. It looks like Tornado uses an alarm and SIGALRM, whereas asyncio only checks elapsed time and so is unable to interrupt a blocked function. Victor Le 7 oct. 2016 20:33, "Yury Selivanov" a écrit : > > > On 2016-10-07 1:31 PM, Giampaolo Rodola' wrote: > >> On Fri, Oct 7, 2016

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-24 Thread Victor Stinner
Similar or related issue recently open and quickly closed: http://bugs.python.org/issue28776 "Duplicate method names should be an error" In short, such job should be done by linters. I'm quite sure that many of them already implement such check. Victor

Re: [Python-ideas] (no subject)

2016-11-29 Thread Victor Stinner
Hi, Python is optimized for performance. Formatting an error message has a cost on performances. I suggest you to teach your student to use the REPL and use a custom exception handler: sys.excepthook: https://docs.python.org/2/library/sys.html#sys.excepthook Using a custom exception handler, you

Re: [Python-ideas] Input characters in strings by decimals (Was: Proposal for default character representation)

2016-12-08 Thread Victor Stinner
FYI you can also get a character by its name: >>> import unicodedata >>> unicodedata.name(chr(1040)) 'CYRILLIC CAPITAL LETTER A' >>> "\N{CYRILLIC CAPITAL LETTER A}" 'А' Victor 2016-12-08 0:52 GMT+01:00 Mikhail V : > In past discussion about inputing and printing characters, > I was proposing dec

Re: [Python-ideas] (no subject)

2016-12-25 Thread Victor Stinner
Le 24 déc. 2016 8:42 PM, "Neil Girdhar" a écrit : > Usually, when an exception is hit that will (probably) crash the program, no one cares about less than a microsecond of performance. Just one example. By design, hasattr(obj, name) raises an exception to return False. So it has the cost of buil

[Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
cale). The topic (switching to UTF-8 on UNIX) is actively discussed on: http://bugs.python.org/issue28180 Read the PEP online (HTML): https://www.python.org/dev/peps/pep-0540/ Victor PEP: 540 Title: Add a new UTF-8 mode Version: $Revision$ Last-Modified: $Date$ Author: Victor Stinner Status:

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
> https://www.python.org/dev/peps/pep-0540/ I read the PEP 538, PEP 540, and issues related to switching to UTF-8. At least, I can say one thing: people have different points of view :-) To understand why people disagree, I tried to categorize the different point of views and Python expectations:

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
2017-01-05 17:50 GMT+01:00 Victor Stinner : > In its current shame, my PEP 540 leaves Python default unchanged, but > adds two modes: UTF-8 and UTF-8 strict. The UTF-8 mode is more or less > the UNIX mode generalized for all inputs and outputs: mojibake is a > feature, just pass byt

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
2017-01-06 0:35 GMT+01:00 Steven D'Aprano : >> Python 3 promotes Unicode everywhere including filenames. A solution to >> support filenames not decodable from the locale encoding was found: the >> ``surrogateescape`` error handler (`PEP 393 >> `_), store u

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
Ok, I modified my PEP: the POSIX locale now enables the UTF-8 mode. 2017-01-05 18:10 GMT+01:00 Victor Stinner : > A common request is that "Python just works" without having to pass a > command line option or set an environment variable. Maybe the default > behaviour should be

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
2017-01-06 2:15 GMT+01:00 INADA Naoki : >>> Always use UTF-8 (...) >>Please don't! (...) > > For stdio (including console), PYTHONIOENCODING can be used for > supporting legacy system. > e.g. `export PYTHONIOENCODING=$(locale charmap)` The problem with ignoring the locale by default and forcin

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
2017-01-06 3:10 GMT+01:00 Stephen J. Turnbull : > I've quoted Victor out of context, and his other posts make me very > doubtful that he considers this a serious alternative. That said, I'm > +1 on "don't!" The "always ignore locale and force UTF-8" option has supporters. For example, Nick Coghla

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-05 Thread Victor Stinner
2017-01-06 3:10 GMT+01:00 Stephen J. Turnbull : > The point of this, I suppose, is that piping to xargs works by > default. Please read the second version (latest) version of my PEP 540 which contains a new "Use Cases" section which helps to define issues and the behaviour of the different modes.

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-06 Thread Victor Stinner
2017-01-06 8:21 GMT+01:00 INADA Naoki : > I want UTF-8 mode is enabled by default (opt-out option) even if > locale is not POSIX, > like `PYTHONLEGACYWINDOWSFSENCODING`. You do, I don't :-) It shouldn't be hard to find very concrete issues from the mojibake issues described at: https://www.python

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-06 Thread Victor Stinner
2017-01-06 7:22 GMT+01:00 Stephan Houben : > How common is this problem? Last 2 or 3 years, I don't recall having be bitten by such issue. On the bug tracker, new issues are opened infrequently. * http://bugs.python.org/issue19977 opened at 2013-12-13, closed at 2014-04-27 * http://bugs.python.o

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-06 Thread Victor Stinner
2017-01-06 10:50 GMT+01:00 M.-A. Lemburg : > Victor: I think you are taking the UTF-8 idea a bit too far. Hum, sorry, the PEP is still a draft, the rationale is far from perfect yet. Let me try to simplify the issue: users are unable to configure a locale for various reasons and expect that Python

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-06 Thread Victor Stinner
2017-01-06 22:20 GMT+01:00 Barry Warsaw : >>Because I have the impression that nowadays all Linux distributions are UTF-8 >>by default and you have to show some bloody-mindedness to end up with a POSIX >>locale. > > It can still happen in some corner cases, even on Debian and Ubuntu where > C.UTF-8

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-06 Thread Victor Stinner
2017-01-07 1:06 GMT+01:00 Barry Warsaw : > For some reason it's not configured: (...) Ok, thanks for the information. > I'm not sure why that's the default inside a chroot. I found at least one good reason to use the POSIX locale to build a package: it helps to get reproductible builds, see: htt

[Python-ideas] RFC: PEP 540 version 3 (Add a new UTF-8 mode)

2017-01-11 Thread Victor Stinner
quot;real world" example instead of a long list of theorical things :-) Read the PEP 540 online (HTML): https://www.python.org/dev/peps/pep-0540/ Full text below. Victor PEP: 540 Title: Add a new UTF-8 mode Version: $Revision$ Last-Modified: $Date$ Author: Victor Stinner Status: Draft Ty

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-11 Thread Victor Stinner
2017-01-06 10:50 GMT+01:00 M.-A. Lemburg : > Victor: I think you are taking the UTF-8 idea a bit too far. > Nick was trying to address the situation where the locale is > set to "C", or rather not set at all (in which case the lib C > defaults to the "C" locale). The latter is a fairly standard > s

Re: [Python-ideas] Settable defaulting to decimal instead of float

2017-01-12 Thread Victor Stinner
George requested this feature on the bug tracker: http://bugs.python.org/issue29223 George was asked to start a discusson on this list. I posted the following comment before closing the issue: You are not the first one to propose the idea. 2012: "make decimal the default non-integer instead of f

Re: [Python-ideas] PEP 540: Add a new UTF-8 mode

2017-01-12 Thread Victor Stinner
2017-01-12 1:23 GMT+01:00 INADA Naoki : > I'm ±0 to surrogateescape by default. I feel +1 for stdout and -1 for stdin. The use case is to be able to write a Python 3 program which works work UNIX pipes without failing with encoding errors: https://www.python.org/dev/peps/pep-0540/#producer-consum

Re: [Python-ideas] RFC: PEP 540 version 3 (Add a new UTF-8 mode)

2017-01-12 Thread Victor Stinner
2017-01-12 9:45 GMT+01:00 INADA Naoki : > As I described in other thread, LC_COLLATE may cause unintentional performance > regression and behavior changes. Since Python 3 uses mostly text, not bytes, LC_COLLATE should not really impact Python applications. Locales set by setlocale() are not inheri

Re: [Python-ideas] Settable defaulting to decimal instead of float

2017-01-12 Thread Victor Stinner
2017-01-12 13:13 GMT+01:00 Stephan Houben : > Something like: > from __syntax__ import decimal_literal IMHO you can already implement that with a third party library, see for example: https://github.com/lihaoyi/macropy It also reminds me my PEP 511 which would open the gate for any kind of Python

Re: [Python-ideas] RFC: PEP 540 version 3 (Add a new UTF-8 mode)

2017-01-12 Thread Victor Stinner
2017-01-12 9:45 GMT+01:00 INADA Naoki : > When using en_US.UTF-8 as fallback, pleas override only LC_CTYPE, > instead of LC_ALL. > As I described in other thread, LC_COLLATE may cause unintentional performance > regression and behavior changes. Does it work to use a locale with encoding A for LC_C

Re: [Python-ideas] RFC: PEP 540 version 3 (Add a new UTF-8 mode)

2017-01-12 Thread Victor Stinner
2017-01-12 17:10 GMT+01:00 Oleg Broytman : >> Does it work to use a locale with encoding A for LC_CTYPE and a locale >> with encoding B for LC_MESSAGES (and others)? Is there a risk of > >It does when B is a subset of A (ascii and koi8; ascii and utf8, e.g.) My question is more when A and B en

Re: [Python-ideas] Fused multiply-add (FMA)

2017-01-16 Thread Victor Stinner
2017-01-15 18:25 GMT+01:00 Juraj Sukop : > C99 includes `fma` function to `math.h` [6] and emulates the calculation if > the FMA instruction is not present on the host CPU [7]. If even the libc function has a fallback on x*y followed by +z, it's fine to add such function to the Python stdlib. It m

[Python-ideas] Is it Python 3 yet?

2017-01-26 Thread Victor Stinner
Hi, The download button of https://www.python.org/ currently gives the choice between Python 2.7 and 3.6. I read more and more articles saying that we reached a point where Python 3 became more popular than Python 2, Python 3 has now enough new features to convince developers, etc. Is it time to

Re: [Python-ideas] Is it Python 3 yet?

2017-01-26 Thread Victor Stinner
If you only want to vote +1 or -1 with no rationale, you may prefer to vote on my Twitter poll: https://twitter.com/VictorStinner/status/824654597235040257 Otherwise, please explain a little bit. Victor ___ Python-ideas mailing list Python-ideas@python.

Re: [Python-ideas] Is it Python 3 yet?

2017-01-26 Thread Victor Stinner
2017-01-26 17:21 GMT+01:00 Paul Moore : > On a similar note, I always get caught out by the fact that the > Windows default download is the 32-bit version. Are we not yet at a > point where a sufficient majority of users have 64-bit machines, and > 32-bit should be seen as a "specialist" choice? A

[Python-ideas] Is it Python 3 yet? Results on my poll on Twitter

2017-02-07 Thread Victor Stinner
Hi, I created the following poll on Twitter with a duration of 7 days: """ Is it Python 3 yet? https://mail.python.org/pipermail/python-ideas/2017-January/01.html I proposed to hide Python 2 by default from the http://python.org download page. ( ) It's Python 3 O'Clock! ( ) Have some legacy p

Re: [Python-ideas] Efficient debug logging

2017-02-16 Thread Victor Stinner
Yeah, I had a similar issue in a previous company. A colleague wrote a script using a regex to remove these debug logs in the .py code. IHMO the clean design for that would be to support officially preprocessors in Python. My PEP opens the gate for that: https://www.python.org/dev/peps/pep-0511/

Re: [Python-ideas] Efficient debug logging

2017-02-16 Thread Victor Stinner
2017-02-16 13:55 GMT+01:00 M.-A. Lemburg : > 1. you don't need a preprocessor for this: simply put your > logging code into an "if __debug__:" block: The problem with -O is that it also disables assertions, whereas you may want to keep them at runtime on production for good reasons. Victor _

[Python-ideas] Positional-only parameters

2017-02-28 Thread Victor Stinner
Hi, For technical reasons, many functions of the Python standard libraries implemented in C have positional-only parameters. Example: --- $ ./python Python 3.7.0a0 (default, Feb 25 2017, 04:30:32) >>> help(str.replace) replace(self, old, new, count=-1, /) # <== notice "/" at the end ...

Re: [Python-ideas] Expose a child factory using MappingProxyType in builtins

2017-02-28 Thread Victor Stinner
2017-02-28 13:17 GMT+01:00 Michel Desmoulin : > We have the immutable frozenset for sets and and tuples for lists. > > But we also have something to manipulate dict as immutable datastructures: > from types import MappingProxyType as idict d = idict({'a':1, 'b':2, 'c':3}) d['a'] = 4

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
2017-03-01 21:52 GMT+01:00 Terry Reedy : > + 1 also. When people write a Python equivalent of a built-in function for > documentation or teaching purposes, they should be able to exactly mimic the > API. Yeah, Serhiy said basically the same thing: it's doable, but complex without builtin support f

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
2017-03-02 14:23 GMT+01:00 Steven D'Aprano : >> Replace "replace(self, old, new, count=-1, /)" with "replace(self, >> old, new[, count=-1])" (or maybe even not document the default >> value?). > > That isn't right. It would have to be: > > replace([self, old, new, count=-1]) > > if all of the argum

Re: [Python-ideas] Optional parameters without default value

2017-03-02 Thread Victor Stinner
I dislike the try/except NameError test to chevk if the parameter is set. Catching NameError is slow. What is the root issue? Function signature in help(func)? If yes, the solution can be a special value understood by inspect.signature(). Should it be possible to pass explicitly the special value

Re: [Python-ideas] Optional parameters without default value

2017-03-02 Thread Victor Stinner
In my code, I commonly use a NOT_SET singleton used as default value. I like this name for the test: if arg is NOT_SET: ... ;-) I use that when I want to behave differently when None is passed. And yes, I have such code. Victor Le 2 mars 2017 9:36 AM, "M.-A. Lemburg" a écrit : On 02.03.2017

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
writing it, Victor, or is someone else going to write > it? > > On Tue, 28 Feb 2017 at 13:18 Victor Stinner > wrote: > >> Hi, >> >> For technical reasons, many functions of the Python standard libraries >> implemented in C have positional-only parameter

Re: [Python-ideas] Optional parameters without default value

2017-03-03 Thread Victor Stinner
2017-03-03 6:13 GMT+01:00 Mike Miller : > Agreed, I've rarely found a need for a "second None" or sentinel either, but > once every few years I do. So, this use case doesn't seem to be common > enough to devote special syntax or a keyword to from my perspective. The question here is how to have a

Re: [Python-ideas] Optional parameters without default value

2017-03-03 Thread Victor Stinner
Since yet another sentinel singleton sounds like a dead end, I suggest to use [arg=value] syntax and require a default value in the prototype, as currently required for *optional keyword* arguments. "[...]" syntax for optional parameter is commonly used in Python documentation (but the exact synta

Re: [Python-ideas] Add socket utilities for IPv4/6 dual-stack servers

2017-03-05 Thread Victor Stinner
Would it be possible to create a PyPI project to experiement the API and wait until we collected enough user feedback first? Currently socket is low level. Not sure if I like the idea of putting more high level features in it? Asyncio is a good place for high level features, but is limited to asyn

Re: [Python-ideas] PEP: Python Documentation Translations

2017-03-21 Thread Victor Stinner
I assigned the number 545 to the PEP. It should be online in less than 2 hours (I don't know what and how PEPs are rendered on python.org) at: https://www.python.org/dev/peps/pep-0545/ Victor ___ Python-ideas mailing list [email protected] https://

Re: [Python-ideas] PEP: Python Documentation Translations

2017-03-21 Thread Victor Stinner
> Python documentation GitHub organization: https://github.com/python-docs/ I tried to create a team in the GitHub Python organization. It works. But then I don't have the right to add new members, since "I'm not an organization owner". IMHO the Python organization is too strict for such translati

Re: [Python-ideas] PEP: Python Documentation Translations

2017-03-21 Thread Victor Stinner
> Contributor Agreement > ' > > Contributions to translated documentation will be requested to sign the > Python Contributor Agreement (CLA): > > https://www.python.org/psf/contrib/contrib-form/ I'm not sure about this requirement, but I'm not a lawyer. I guess that in case of

Re: [Python-ideas] PEP: Python Documentation Translations

2017-03-23 Thread Victor Stinner
2017-03-22 2:14 GMT+01:00 Victor Stinner : >> Python documentation GitHub organization: https://github.com/python-docs/ > > I tried to create a team in the GitHub Python organization. It works. > But then I don't have the right to add new members, since "I'm not an &

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Victor Stinner
*If* we change something, I would prefer to modify sys.stdout. The following issue proposes to add sys.stdout.set_encoding(errors='replace'): http://bugs.python.org/issue15216 You can already set the PYTHONIOENCODING environment variable to ":replace" to use "replace" on sys.stdout (and sys.stderr

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Victor Stinner
unction as shown in a previous email. Victor Le 25 mars 2017 8:50 PM, "Michel Desmoulin" a écrit : Le 24/03/2017 à 17:37, Victor Stinner a écrit : > *If* we change something, I would prefer to modify sys.stdout. The > following issue proposes to add > sys.stdout.set_encod

Re: [Python-ideas] Add pathlib.Path.write_json and pathlib.Path.read_json

2017-03-27 Thread Victor Stinner
2017-03-27 17:04 GMT+02:00 Steven D'Aprano : > Of course pathlib can already read JSON, or for that matter ReST text > or JPG binary files. It can read anything as text or bytes, including > JSON: > > some_path.write_text(json.dumps(obj)) > json.loads(some_path.read_text()) Note: You should specif

Re: [Python-ideas] Thread-safe generators

2017-04-16 Thread Victor Stinner
Thread safety is very complex and has an impact on performance. I dislike the idea of providing such property to generators which can have a complex next method. IMHO it's better to put a generator in wrapper which adds thread safety. What do you think? Victor Le 14 avr. 2017 18:48, "Serhiy Sto

Re: [Python-ideas] Add a .chunks() method to sequences

2017-05-04 Thread Victor Stinner
> How about adding a chunks() and rchunks() function to sequences: > > [1,2,3,4,5,6,7].chunks(3) => [[1,2,3], [4,5,6], [7]] I prefer str.join() approach: write a single chunks() function which takes a sequence, instead of modifying all sequence types around the world ;-) It's less natural to writ

Re: [Python-ideas] Add a .chunks() method to sequences

2017-05-04 Thread Victor Stinner
2017-05-05 0:20 GMT+02:00 Greg Ewing : > While most uses would probably be for short strings, I can > think of uses cases involving large ones. For example, to > format a hex dump into lines with 8 bytes per line and spaces > between the lines: For such specialized use case, write a C extension.

Re: [Python-ideas] π = math.pi

2017-06-01 Thread Victor Stinner
2017-06-01 8:47 GMT+02:00 Serhiy Storchaka : > What you are think about adding Unicode aliases for some mathematic names in > the math module? ;-) > > math.π = math.pi How do you write π (pi) with a keyboard on Windows, Linux or macOS? Victor ___ Python

Re: [Python-ideas] SealedMock proposal for unittest.mock

2017-06-01 Thread Victor Stinner
A stricter mock object cannot be a bad idea :-) I am not sure about your proposed API: some random code may already use this attribute. Maybe it can be a seal (mock) function which sets a secret attribute with a less common name? Yeah, please open an issue on bugs.python.org ;-) Victor Le 29 ma

[Python-ideas] Security: remove "." from sys.path?

2017-06-01 Thread Victor Stinner
Hi, Perl 5.26 succeeded to remove the current working directory from the default include path (our Python sys.path): https://metacpan.org/pod/release/XSAWYERX/perl-5.26.0/pod/perldelta.pod#Removal-of-the-current-directory-(%22.%22)-from-@INC Would it technically possible to make this change in P

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-01 Thread Victor Stinner
> (AIUI, the *current directory* is never on Python's path, but the *script directory* is. They're the same thing a lot of the time.) Oh, it's very common that I run a script from its directory, so yeah script directory = current directory on such case. Sorry for the confusion. You are right, it's

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-02 Thread Victor Stinner
2017-06-02 9:12 GMT+02:00 Greg Ewing : > Why do you want to change it? To make Python more secure. To prevent untrusted modules hijacking stdlib modules on purpose to inject code for example. Victor ___ Python-ideas mailing list [email protected]

Re: [Python-ideas] Security: remove "." from sys.path?

2017-06-05 Thread Victor Stinner
Le 5 juin 2017 00:52, "Guido van Rossum" a écrit : I really don't want people to start using the "from . import foo" idiom for their first steps into programming. It seems a reasonable "defensive programming" maneuver to put in scripts and apps made by professional Python programmers for surpris

Re: [Python-ideas] Dictionary destructing and unpacking.

2017-06-07 Thread Victor Stinner
> In python 3.6+ this is better since the dictionary is insertion-ordered, but is still not really what one would probably want. Be careful: ordered dict is an implementation detail. You must use explicitly collections.OrderedDict() to avoid bad surprises. In CPython 3.7, dict might change again.

Re: [Python-ideas] socket module: plain stuples vs named tuples

2017-06-19 Thread Victor Stinner
Hi, 2017-06-13 22:13 GMT+02:00 Thomas Güttler : > AFAIK the socket module returns plain tuples in Python3: > > https://docs.python.org/3/library/socket.html > > Why not use named tuples? For technical reasons: the socket module is mostly implemented in the C language, and define a "named tuple"

Re: [Python-ideas] socket module: plain stuples vs named tuples

2017-06-19 Thread Victor Stinner
; (First open an issue stating that you're interested; point to this email > from me to prevent that some other core dev just closes it again.) > > On Mon, Jun 19, 2017 at 2:24 PM, Victor Stinner > wrote: > >> Hi, >> >> 2017-06-13 22:13 GMT+02:00 Thomas Gü

Re: [Python-ideas] socket module: plain stuples vs named tuples

2017-06-20 Thread Victor Stinner
2017-06-20 4:05 GMT+02:00 INADA Naoki : > Namedtuple in Python make startup time slow. > So I'm very conservative to convert tuple to namedtuple in Python. > INADA Naoki While we are talking about startup time, I would be curious of seeing the overhead (python startup time, when importing socket

Re: [Python-ideas] Python 4: Concatenation

2017-06-30 Thread Victor Stinner
2017-06-30 1:33 GMT+02:00 Soni L. : > Step 3. add decimal concatenation operator for numbers: 2 cat 3 == 23, 22 > cat 33 = 2233, etc. if you need bitwise concatenation, you're already in > bitwise "hack" land so do it yourself. (no idea why bitwise is considered > hacky as I use it all the time, bu

Re: [Python-ideas] Bytecode JIT

2017-06-30 Thread Victor Stinner
2017-06-30 17:09 GMT+02:00 Soni L. : > CPython should get a tracing JIT that turns slow bytecode into fast > bytecode. > > A JIT doesn't have to produce machine code. bytecode-to-bytecode compilation > is still compilation. bytecode-to-bytecode compilation works on iOS, and > doesn't require deviat

Re: [Python-ideas] Bytecode JIT

2017-07-01 Thread Victor Stinner
Let's say that you have a function "def mysum (x; y): return x+y", do you always want to use your new IADD instruction here? What if I call mysum ("a", "b")? Victor ___ Python-ideas mailing list [email protected] https://mail.python.org/mailman/lis

Re: [Python-ideas] Bytecode JIT

2017-07-03 Thread Victor Stinner
2017-07-02 14:13 GMT+02:00 Steven D'Aprano : > That only solves the problem of mysum being modified, not whether the > arguments are ints. You still need to know whether it is safe to call > some low-level (fast) integer addition routine, or whether you have to > go through the (slow) high-level Py

[Python-ideas] PEP: Hide implementation details in the C API

2017-07-11 Thread Victor Stinner
master/2017-PyconUS/summit.pdf Since this is really the first draft, I didn't assign a PEP number to it yet. I prefer to wait for a first feedback round. Victor PEP: xxx Title: Hide implementation details in the C API Version: $Revision$ Last-Modified: $Date$ Author: Victor Stinner , Status:

Re: [Python-ideas] PEP: Hide implementation details in the C API

2017-07-11 Thread Victor Stinner
> Step 3: first pass of implementation detail removal > --- > > Modify the ``python`` API: > > * Add a new ``API`` subdirectory in the Python source code which will > "implement" the Python C API > * Replace macros with functions. The implementation

Re: [Python-ideas] PEP: Hide implementation details in the C API

2017-07-13 Thread Victor Stinner
2017-07-13 0:23 GMT+02:00 Stefan Behnel : > From a Cython perspective, it's (not great but) ok if these "implementation > details" were moved somewhere else, but it would be a problem if they > became entirely unavailable for external modules. Cython uses some of the > internals for performance rea

Re: [Python-ideas] PEP: Hide implementation details in the C API

2017-07-13 Thread Victor Stinner
2017-07-12 20:51 GMT+02:00 Brett Cannon : > I also think the motivation doesn't have to be performance but simply > cleaning up how we expose our C APIs to users as shown by the fact we have > messed up the stable API by making it opt-out instead of opt-in. It's hard to sell a "cleanup" to users w

Re: [Python-ideas] PEP: Hide implementation details in the C API

2017-07-13 Thread Victor Stinner
2017-07-13 15:21 GMT+02:00 Nick Coghlan : > As far as I know, this isn't really why folks find the stable ABI hard > to switch to. Rather, I believe it's because switching to the stable > ABI means completely changing how you define classes to be closer to > the way you define them from Python code

Re: [Python-ideas] Alternative Unicode implementations (NSString/NSMutableString)

2017-07-18 Thread Victor Stinner
Supporting a new kind of string storage would require a lot of efforts. There are a lot of C code specialized for each Unicode kind Victor Le 19 juil. 2017 12:43 AM, "Jim J. Jewett" a écrit : > Ronald Oussoren came up with a concrete use case for wanting the > interpreter to consider something

Re: [Python-ideas] Alternative Unicode implementations (NSString/NSMutableString)

2017-07-19 Thread Victor Stinner
2017-07-19 4:34 GMT+02:00 Nick Coghlan : > 2. Indicate that it's a "lazily rendered" subclass that should hold > off on calling PyUnicode_Ready for as long as possible, but still do > so when necessary (akin to creating strings via the old Py_UNICODE > APIs and then calling PyUnicode_READY on them)

Re: [Python-ideas] namedtuple literals [Was: RE a new namedtuple]

2017-07-20 Thread Victor Stinner
For me, namedtuple was first used to upgrade an old API from returning a tuple to a "named" tuple. There was a hard requirement on backward compatibility: namedtuple API is a superset of the tuple API. For new code, there is no such backward compatibility issue. If you don't need a type, types.Nam

Re: [Python-ideas] Fwd: Consider allowing the use of abstractmethod without metaclasses

2017-07-20 Thread Victor Stinner
Le 20 juil. 2017 3:49 AM, "INADA Naoki" a écrit : > I'm +1 with your idea in performance point of view. (...) But ABC is too heavy to use only for checking abstract methods. It uses three inefficient WeakSet [1] and it overrides isinstance and issubclass with slow Python implementation. I don't

Re: [Python-ideas] Pseudo methods

2017-08-07 Thread Victor Stinner
Ruby provides this feature. A friend who is a long term user of Rails complained that Rails abuses this and it's a mess in practice. So I dislike this idea. Victor 2017-08-04 9:39 GMT+02:00 Paul Laos : > Hi folks > I was thinking about how sometimes, a function sometimes acts on classes, > and >

Re: [Python-ideas] Adding "View Python 3 Documentation" to all Python 2 documentation URLs

2017-09-06 Thread Victor Stinner
Another example is PyPI showing a bold "Latest version: x.x.x". Example: https://pypi.python.org/pypi/requests/2.17.0 Victor 2017-09-07 0:52 GMT+02:00 Ryan Gonzalez : > Right now, many Google searches for Python modules return the Python 2 > documentation. IMO since 2 will be reaching EOL in arou

Re: [Python-ideas] Hexadecimal floating literals

2017-09-08 Thread Victor Stinner
2017-09-07 23:57 GMT-07:00 Serhiy Storchaka : > The support of hexadecimal floating literals (like 0xC.68p+2) is included in > just released C++17 standard. Seems this becomes a mainstream. Floating literal using base 2 (or base 2^n, like hexadecimal, 2^4) is the only way to get exact values in a

Re: [Python-ideas] Hexadecimal floating literals

2017-09-11 Thread Victor Stinner
Instead of modifying the Python grammar, the alternative is to enhance float(str) to support it: k = float("0x1.2492492492492p-3") # 1/7 Victor 2017-09-08 8:57 GMT+02:00 Serhiy Storchaka : > The support of hexadecimal floating literals (like 0xC.68p+2) is included in > just released C++17 standa

Re: [Python-ideas] Hexadecimal floating literals

2017-09-12 Thread Victor Stinner
2017-09-12 3:48 GMT+02:00 Steven D'Aprano : >> k = float("0x1.2492492492492p-3") # 1/7 > > Why wouldn't you just write 1/7? 1/7 is irrational, so it's not easy to get the "exact value" for a 64-bit IEEE 754 double float. I chose it because it's easy to write. Maybe math.pi is a better example :-)

Re: [Python-ideas] Hexadecimal floating literals

2017-09-12 Thread Victor Stinner
2017-09-12 1:27 GMT+02:00 Neil Schemenauer : >> k = float("0x1.2492492492492p-3") # 1/7 > > Making it a different function from float() would avoid backwards > compatibility issues. I.e. float() no longer returns errors on some > inputs. In that case, I suggest float.fromhex() to remain consistent

[Python-ideas] Move some regrtest or test.support features into unittest?

2017-09-13 Thread Victor Stinner
Hi, tl; dr How can we extend unittest module to plug new checks before/after running tests? The CPython project has a big test suite in the Lib/test/ directory. While all tests are written with the unittest module and the unittest.TestCase class, tests are not run directly by unittest, but run b

Re: [Python-ideas] sys.py

2017-09-14 Thread Victor Stinner
Le 14 sept. 2017 01:01, "Eric Snow" a écrit : In the case of sys.modules, the problem is that assigning a bogus value (e.g. []) can cause the interpreter to crash. It wasn't a problem until recently when I removed PyInterpreterState.modules and made sys.modules authoritative (see https://bugs.py

Re: [Python-ideas] Move some regrtest or test.support features into unittest?

2017-09-18 Thread Victor Stinner
Antoine: >> * skip a test if it allocates too much memory, command line argument >> to specify how many memory a test is allowed to allocate (ex: >> --memlimit=2G for 2 GB of memory) > > That would be suitable for a plugin if unittest had a plugin > architecture, but not as a core functionality IMO

Re: [Python-ideas] Move some regrtest or test.support features into unittest?

2017-09-19 Thread Victor Stinner
>> * --timeout: watchdog killing the test if the run time exceed the >> timeout in seconds (use faulthandler.dump_traceback_later) > > This feature looks functionally similar to limiting memory usage. Hum, I don't think so. Limiting the memory usage doesn't catch deadlocks for example. Victor ___

Re: [Python-ideas] Hexadecimal floating literals

2017-09-21 Thread Victor Stinner
2017-09-21 3:53 GMT+02:00 Steven D'Aprano : > float.fromhex(s) if s.startswith('0x') else float(s) My vote is now -1 on extending the Python syntax to add hexadecimal floating literals. While I was first in favor of extending the Python syntax, I changed my mind. Float constants written in hexade

Re: [Python-ideas] Changes to the existing optimization levels

2017-09-28 Thread Victor Stinner
> 2) Added a new command line option N that allows you to specify > any number of individual optimization flags. > > For example: > > python -N nodebug -N noassert -N nodocstring You may want to look at my PEP 511 which proposes to add a new "-o" option to specify a list of optimiz

Re: [Python-ideas] PEP 560 (second post)

2017-09-29 Thread Victor Stinner
> Title: Core support for generic types Would it be possible to mention "typing" somewhere in the title? If you don't know the context, it's hard to understand that the PEP is related to type annotation and type checks. At least just from the title. Victor

[Python-ideas] Add time.time_ns(): system clock with nanosecond resolution

2017-10-13 Thread Victor Stinner
Hi, I would like to add new functions to return time as a number of nanosecond (Python int), especially time.time_ns(). It would enhance the time.time() clock resolution. In my experience, it decreases the minimum non-zero delta between two clock by 3 times, new "ns" clock versus current clock: 8

Re: [Python-ideas] Add time.time_ns(): system clock with nanosecond resolution

2017-10-13 Thread Victor Stinner
2017-10-13 16:57 GMT+02:00 Stefan Behnel : > I might have missed it while skipping through your post, but could you > quickly explain why improving the precision of time.time() itself wouldn't > help already? Would double FP precision not be accurate enough here? 80-bit binary float ("long double"

Re: [Python-ideas] Add time.time_ns(): system clock with nanosecond resolution

2017-10-15 Thread Victor Stinner
> (That being said, I'm a big fan of fractions, so I wonder if a Fraction with a constant nano denominator wouldn't fit in here...) It was discussed in depth in PEP 410, and the PEP was rejected. Guido voted for nanoseconds as int, when os.stat_result.st_mtime_ns was added. Victor ___

Re: [Python-ideas] Add time.time_ns(): system clock with nanosecond resolution

2017-10-15 Thread Victor Stinner
> Might it make more sense to have a parallel *module* that works with a different base data type rather than parallel functions within the existing API? I asked about adding new functions to 4 different modules: os, resource, signal, time. For example, I dislike the idea of having os and os_ns m

  1   2   >