[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

[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 ___

[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

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

2019-10-17 Thread Victor Stinner
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 Add

Re: [Python-ideas] Adding str.isascii() ?

2018-01-31 Thread Victor Stinner
I like the idea of str.isdigit(ascii=True): would behave as str.isdigit() and str.isascii(). It's easy to implement and likely to be very efficient. I'm just not sure that it's so commonly required? At least, I guess that some users can be surprised that str.isdigit() is "Unicode aware", accept

Re: [Python-ideas] Why CPython is still behind in performance for some widely used patterns ?

2018-01-26 Thread Victor Stinner
Hi, Well, I wrote https://faster-cpython.readthedocs.io/ website to answer to such question. See for example https://faster-cpython.readthedocs.io/mutable.html "Everything in Python is mutable". Victor 2018-01-26 22:35 GMT+01:00 Pau Freixes : > Hi, > > This mail is the

Re: [Python-ideas] Adding str.isascii() ?

2018-01-26 Thread Victor Stinner
2018-01-26 14:43 GMT+01:00 M.-A. Lemburg : > If that's indeed being used as assumption, the docs must be > fixed and PyUnicode_New() should verify this assumption as > well - not only in debug builds using C asserts() :-) As PyUnicode_FromStringAndSize(NULL, size),

Re: [Python-ideas] Adding str.isascii() ?

2018-01-26 Thread Victor Stinner
2018-01-26 13:39 GMT+01:00 Steven D'Aprano : > I have no objection to isascii, but I don't think it goes far enough. > Sometimes I want to know whether a string is compatible with Latin-1 or > UCS-2 as well as ASCII. For that, I used a function that exposes the > size of code

Re: [Python-ideas] Adding str.isascii() ?

2018-01-26 Thread Victor Stinner
2018-01-26 12:17 GMT+01:00 INADA Naoki : >> No, because you can pass in maxchar to PyUnicode_New() and >> the implementation will take this as hint to the max code point >> used in the string. There is no check done whether maxchar >> is indeed the minimum upper bound to

Re: [Python-ideas] Adding str.isascii() ?

2018-01-26 Thread Victor Stinner
+1 The idea is not new and I like it. Naoki created https://bugs.python.org/issue32677 Victor 2018-01-26 11:22 GMT+01:00 Antoine Pitrou : > On Fri, 26 Jan 2018 17:42:31 +0900 > INADA Naoki > wrote: >> >> If str has str.isascii() method, it can be

Re: [Python-ideas] Make functions, methods and descriptor types living in the types module

2018-01-11 Thread Victor Stinner
I like the idea of having a fully qualified name that "works" (can be resolved). I don't think that repr() should change, right? Can this change break the backward compatibility somehow? Victor Le 11 janv. 2018 21:00, "Serhiy Storchaka" a écrit : > Currently the classes

Re: [Python-ideas] Add an UML class diagram to the collections.abc module documentation

2018-01-01 Thread Victor Stinner
Hi, There is "blockdiag" which is Sphinx friendly: http://blockdiag.com/en/blockdiag/sphinxcontrib.html Look also at: * http://asciiflow.com/ * http://ditaa.sourceforge.net/ * http://asciidoctor.org/news/2014/02/18/plain-text-diagrams-in-asciidoctor/ * etc. I like ASCII Art since it doesn't

Re: [Python-ideas] Immutable dictionaries

2017-11-29 Thread Victor Stinner
2017-11-29 18:30 GMT+01:00 Asen Bozhilov : > I'd like to propose also literaling syntax for immutable dictionaries. > > immutable_dict = ( > 'key1' : 'value1', > 'key2' : 'value2' > ) Since Python 3.3, you can write: vstinner@apu$ python3 Python 3.6.3 (default,

Re: [Python-ideas] Should Python have user-defined constants?

2017-11-21 Thread Victor Stinner
2017-11-21 7:33 GMT+01:00 Saeed Baig : > Hey guys I am thinking of perhaps writing a PEP to introduce user-defined > constants to Python. Something along the lines of Swift’s “let” syntax (e.g. > “let pi = 3.14”). If you want to work on a PEP, you will have to write a

Re: [Python-ideas] Make bytes __repr__ and __str__ representation different?

2017-11-21 Thread Victor Stinner
Hi, While it may shock you, using bytes for "text" makes sense in some areas. Please read the Motivation of the PEP 461: https://www.python.org/dev/peps/pep-0461/#motivation Victor 2017-11-21 15:37 GMT+01:00 Kirill Balunov : > Currently, __repr__ and __str__

Re: [Python-ideas] Ignorable whitespaces in the re.VERBOSE mode

2017-11-17 Thread Victor Stinner
I don't think that we need more than space (U+0020) and Unix newline (U+000A) ;-) Victor 2017-11-16 11:23 GMT+01:00 Serhiy Storchaka : > Currently the re module ignores only 6 ASCII whitespaces in the re.VERBOSE > mode: > > U+0009 CHARACTER TABULATION > U+000A LINE

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

2017-10-20 Thread Victor Stinner
Hi francis, Le 20 oct. 2017 18:42, "francismb" <franci...@email.de> a écrit : Hi Victor, On 10/13/2017 04:12 PM, Victor Stinner wrote: > I would like to add: > > * time.time_ns() > * time.monotonic_ns() > * time.perf_counter_ns() > * time.clock_gettime_ns() &g

Re: [Python-ideas] Why not picoseconds?

2017-10-20 Thread Victor Stinner
Antoine Pitrou: > Given the implementation costs, hardware decimal128 will only become > mainstream if there's a strong incentive for it, which I'm not sure > exists or will ever exist ;-) Stefan Behnel: > Then we shouldn't implement the new nanosecond API at all, in order to keep > pressure on

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

2017-10-16 Thread Victor Stinner
2017-10-16 18:13 GMT+02:00 Todd : > I am not suggesting implementing a new numeric data type. People wouldn't > use the class directly like they would an int or float, they would simply > use it to define the the precision and numeric type (float, int, decimal). > Then they

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

2017-10-16 Thread Victor Stinner
Hi, FYI I proposed the PEP 564 on python-dev. "PEP 564 -- Add new time functions with nanosecond resolution" https://www.python.org/dev/peps/pep-0564/ Victor ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] Why not picoseconds?

2017-10-16 Thread Victor Stinner
2017-10-16 9:46 GMT+02:00 Stephan Houben : > Hi all, > > I realize this is a bit of a pet peeve of me, since > in my day job I sometimes get people complaining that > numerical data is "off" in the sixteenth significant digit > (i.e. it was stored as a double). > (...) Oh.

Re: [Python-ideas] Why not picoseconds?

2017-10-16 Thread Victor Stinner
Hi, FYI I proposed the PEP 564 directly on python-dev. The paragraph about "picosecond": https://www.python.org/dev/peps/pep-0564/#sub-nanosecond-resolution Let's move the discussion on python-dev ;-) Victor ___ Python-ideas mailing list

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

2017-10-16 Thread Victor Stinner
Hi, > What if we had a class, say time.time_base. The user could specify the base > units (such as "s", "ns", 1e-7, etc) and the data type ('float', 'int', > 'decimal', etc.) when the class is initialized. (...) It's easy to invent various funny new types for arbitrary precision. But I prefer

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

2017-10-16 Thread Victor Stinner
2017-10-16 3:19 GMT+02:00 Juancarlo Añez : > It could be: time.time(ns=True) Please read my initial message: """ [PEP 410] was rejected for different reasons: (...) * Guido van Rossum rejected the idea of adding a new optional parameter to change the result type: it's an

Re: [Python-ideas] Why not picoseconds?

2017-10-15 Thread Victor Stinner
APIs are expensive and we'd like to be future-proof, why not > move to picoseconds? That would be safe until clocks reach the THz > barrier, which is quite far away from us. > > Regards > > Antoine. > > > On Fri, 13 Oct 2017 16:12:39 +0200 > Victor Stinner <victor.st

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

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

[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:

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

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

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

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] 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

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

[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

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

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

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

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

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

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

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,

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

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

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

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

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

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

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 Python-ideas@python.org

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 >

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

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

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

2017-06-19 Thread Victor Stinner
n create a PR? > (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 <victor.stin...@gmail.com> > wrote: > >> Hi, >>

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

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

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

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

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,

[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

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

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

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

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

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

2017-03-26 Thread Victor Stinner
as shown in a previous email. Victor Le 25 mars 2017 8:50 PM, "Michel Desmoulin" <desmoulinmic...@gmail.com> 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.s

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

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

2017-03-23 Thread Victor Stinner
2017-03-22 2:14 GMT+01:00 Victor Stinner <victor.stin...@gmail.com>: >> 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 ne

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-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

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 Python-ideas@python.org

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

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

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

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
PEP. Are you up for writing it, Victor, or is someone else going to write > it? > > On Tue, 28 Feb 2017 at 13:18 Victor Stinner <victor.stin...@gmail.com> > wrote: > >> Hi, >> >> For technical reasons, many functions of the Python standard libraries >> implemente

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

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]) >

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

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,

[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] 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/

[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

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

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] 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] 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

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

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:

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

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

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

2017-01-11 Thread Victor Stinner
ot;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 <victor.stin...@gmail.

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

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

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

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

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

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

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 <victor.stin...@gmail.com>: > A common request is that "Python just works" without having to pass a > command line option or set an environment variable. Maybe t

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

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

2017-01-05 Thread Victor Stinner
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 <victor.stin

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

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,

  1   2   >