[Python-ideas] Re: Fixing and improving statement caching in sqlite3

2020-12-30 Thread Inada Naoki
y used keys are eventually evicted. (behaves like least recently frequently used?) * Minimum overhead for managing keys. So I think a random eviction algorithm is better than LRU. Off topic: Can we add random_cache to functools, like lru_cache?

[Python-ideas] Re: asyncio.to_process function, similar to asyncio.to_thread function

2021-01-03 Thread Inada Naoki
tion for the > ProcessPoolExecutor, e.g. asyncio.to_process? > asyncio.to_thread doesn't use ThreadPoolExecutor. Since thread is cheap, the function create a new thread every time. On the other hand, process is not cheap. That's why the only thread has convenient way to run funct

[Python-ideas] Making TYPE_CHECKING builtin.

2021-01-18 Thread Inada Naoki
will break existing `from typing import TYPE_CHECKING` codes. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/li

[Python-ideas] Re: Making TYPE_CHECKING builtin.

2021-01-18 Thread Inada Naoki
Thank you! I didn't know that. I will use `if False: # TYPE_CHECKING` so the compiler will remove all imports inner it. But the official way is preferred so that all typing ecosystems follow it. -- Inada Naoki ___ Python-ideas mailing

[Python-ideas] Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-22 Thread Inada Naoki
="locale"` instead of `encoding=locale.getpreferredencoding(False)` when they need to use locale encoding. We might change more places where the default encoding is used. But it should be done slowly and carefully. --- How do you think about this idea? Is t

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
o take X versions and multiple deprecation phases), rather > than aiming for a messy goal where people aren't sure which function > to use? > Ultimate goal is make the "utf-8" default. But I don't know when we can change it. So I focus on what we can do in near future (&

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
On Sat, Jan 23, 2021 at 2:43 PM Random832 wrote: > > On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote: > > * Default encoding is "utf-8". > > it might be worthwhile to be a little more sophisticated than this. > > Notepad itself uses character set detection

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
nge the default encoding or not. Please read the first motivation section in the PEP. https://www.python.org/dev/peps/pep-0597/#using-the-default-encoding-is-a-common-mistake Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
ocess repeated again. Yes, if we can change the default encoding in 2030, two open functions will become messy. But there is no promise for the change. Without mitigating the pain, we can not change the default encoding forever. Anyway, thank you for your feedback. Two people prefer `encodin

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
BOM is not recommended, and Notepad uses UTF-8 without BOM as default encoding from 1903, UTF-8 with BOM is still used in some cases. For example, Excel reads CSV file with UTF-8 with BOM or legacy encoding. So some CSV files is written with BOM. Regards, -- Inada Naoki __

[Python-ideas] Changing the default text encoding of pathlib

2021-01-24 Thread Inada Naoki
urse, we need a regular deprecation period. When encoding is omitted, they emit DeprecationWarning (or EncodingWarning which is a subclass of DeprecationWarning) in three versions (Python 3.10~3.12). How do you think this idea? Should we "change

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-25 Thread Inada Naoki
* "b" is not allowed for mode. (*) Another option is to use "utf-8-sig" for reading and "utf-8" for writing. But it has some drawbacks. utf-8-sig has overhead because it is a wrapper implemented in Python. And TextIOWrapper has fast-pa

[Python-ideas] Provide UTF-8 version of Python for Windows.

2021-01-25 Thread Inada Naoki
important information for us. Of course, there are some downsides: * Windows team needs to maintain more versions. * More divisions for "Python on Windows" environment. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-idea

[Python-ideas] Re: Provide UTF-8 version of Python for Windows.

2021-01-25 Thread Inada Naoki
As my understanding, "Fusion manifest for an unpackaged Win32 app" (*) works for non Store Apps too. (*) https://docs.microsoft.com/ja-jp/windows/uwp/design/globalizing/use-utf8-code-page#examples -- Inada Naoki ___ Python-ideas ma

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-25 Thread Inada Naoki
; >> Maybe, we need to update the tutorial (*) to use `encoding="utf-8"`. > > > Telling people to always add `encoding='utf8'` makes much more sense to me > than introducing a new function and telling them to do that. > Ok, I will not add open_utf8() to PEP 597,

[Python-ideas] Re: Provide UTF-8 version of Python for Windows.

2021-01-25 Thread Inada Naoki
statistics wouldn't be tracked, unless the installer > phones home. Can pip send `locale.getpreferredencoding(False)` to PyPI? If so, we can set `PYTHONUTF8` environment variable from the installer too. Or we can provide small tool to set/unset `PYTHONUTF8`

[Python-ideas] Re: Provide UTF-8 version of Python for Windows.

2021-01-26 Thread Inada Naoki
ode by default. * "Python (ANSI version)" will disable the UTF-8 mode by default. User can override the default by `-Xutf8` option and `PYTHONUTF8` environment variable. Does this idea make sense? -- Inada Naoki ___ Python-ideas ma

[Python-ideas] Re: Provide UTF-8 version of Python for Windows.

2021-01-26 Thread Inada Naoki
the subprocess.PIPE encoding in UTF-8 mode. I need to reconsider about stdin/stdout encoding when they are redirected. Maybe, we can use GetConsoleCP() for stdin encoding, and GetConsoleOutputCP() for output encoding. I will write another proposal for it. -- Inada Naoki __

[Python-ideas] Make UTF-8 mode more accessible for Windows users.

2021-01-27 Thread Inada Naoki
ide a small tool to allow configuration after installation? * python3 -m utf8mode enable|disable? * Accessible only for CLI user * Add "Enable UTF-8 mode" and "Disable UTF-8 mode" to Start menu? Any ideas are welcome. -- Inada Naoki

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-01-28 Thread Inada Naoki
use UTF-8 mode consistently. But it will break legacy applications running on old Python environment. If we have per-environment option, it's easy to recommend users to enable UTF-8 mode. > Maybe this would be a good thing to do once there are Warnings in place? > Do you mean prog

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-01-28 Thread Inada Naoki
On Fri, Jan 29, 2021 at 12:54 PM Ben Rudiak-Gould wrote: > > On Wed, Jan 27, 2021 at 11:36 PM Inada Naoki wrote: >> >> * UnicodeDecodeError is raised when trying to open a text file written in >> UTF-8, such as JSON. >> * UnicodeEncodeError is raised when trying to

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-01-30 Thread Inada Naoki
On Sat, Jan 30, 2021 at 3:45 PM Christopher Barker wrote: > > On Thu, Jan 28, 2021 at 4:25 PM Inada Naoki wrote: >> >> > The "real" solution is to change the defaults not to use the system >> > encoding at all -- which, of course, we are moving towards w

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-01 Thread Inada Naoki
On Tue, Feb 2, 2021 at 6:31 AM Barry Scott wrote: > >> On 30 Jan 2021, at 12:05, Inada Naoki wrote: >> >> Where would Python look for a "configuration file like `pyvenv.cfg`" ? >> >> I am not a Windows expert so I am not sure. But I think it should be

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-04 Thread Inada Naoki
No need to edit any file outside the install location. * Easy to clean uninstall * Portable app friendly * One file per environment * Breaking the config file affects only one environment. So I still prefer pyvenv.cfg. -- Inada Naoki ___ Python-idea

[Python-ideas] Re: Add a couple of options to open()'s mode parameter to deal with common text encodings

2021-02-04 Thread Inada Naoki
On Fri, Feb 5, 2021 at 8:20 AM Ben Rudiak-Gould wrote: > > > It seems as though most of those commenting in the other thread don't > actually use Python on Windows. I do, and I can say it's a royal pain to have > to write open(path, encoding='utf-8') all the time. If you could write > open(path

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Inada Naoki
would not help. > But a python.ini could. > python.exe lookup pyvenv.cfg even outside of venv. So we can write utf8mode=1 in pyvenv.cfg even outside of venv. The main limitation is that users can not write config file in install location when Python is installed for system, not for us

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-05 Thread Inada Naoki
> > Also am I right to assume that the impact of these changes would only impact > on Windows? > I think we don't have any reason to restrict this for Windows. But since this idea is proposed only for Windows users, only Windows installer will have "Enable UTF-8 mode&quo

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-06 Thread Inada Naoki
ut strong need. Currently, a per-install setting is not possible. So it is the only problem. If adding option to pyvenv.cfg is not make sense, we can add `python.ini` to same place pyvenv.cfg. i.e., directory containing python.exe, or one above directory. -- Inada Naoki _

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-07 Thread Inada Naoki
But I don't think it's enough reason to put a new config file to user profile. If users don't have system privilege, they can still install another Python. Config file in user profile is fragile. If all venvs start using profile directory, it become unmaintainable soon. We can

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-07 Thread Inada Naoki
r beginners use UTF-8 locale by default. There is no guarantee. But if default locale is not UTF-8, I don't think the environment is suited for beginners who learning to Python. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-08 Thread Inada Naoki
(CI) > environments might need it too. > Unlike Windows, environment variables work very fine for such use cases. On Unix, direnv, dotenv, and maybe more tools are there. It is not only for Python, but for projects. > Which is another good rea

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-08 Thread Inada Naoki
On Tue, Feb 9, 2021 at 3:37 PM Christopher Barker wrote: > > On Mon, Feb 8, 2021 at 6:11 PM Inada Naoki wrote: >> >> > >> Unlike Windows, environment variables work very fine for such use cases. > > > Windows has environment variables, doesn't it? >

[Python-ideas] Re: class(obj) could return obj.__class__

2021-02-08 Thread Inada Naoki
n-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/TMFUKID6KMTEAZAS4ILBHSG23GGYNCS4/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Inada

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-09 Thread Inada Naoki
On Tue, Feb 9, 2021 at 4:53 PM Christopher Barker wrote: > >> >> because UTF-8 mode helps many Windows users but it is not accessible >> enough for Windows users. > > > It's not just accessibility, but discoverability -- Windows users -- and even > more so developers that don't generally use Wind

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-09 Thread Inada Naoki
; your configuration via the application and using the registry. > > Perhaps we could have both: an env var to enable UTF-8 mode and > a registry key set by the installer. > I don't want to recommend env vars and registry for conda and portable Python users... -- Inada Naoki ___

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-09 Thread Inada Naoki
On Wed, Feb 10, 2021 at 6:02 AM Paul Moore wrote: > > On Tue, 9 Feb 2021 at 17:32, Inada Naoki wrote: > > > > On Tue, Feb 9, 2021 at 7:42 PM M.-A. Lemburg wrote: > > > > > > Here's a good blog post about setting env vars on Windows: > > > &g

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-10 Thread Inada Naoki
mend it to > > anyone. It was a nightmare when folks have Python 2 and 3 on the same > > machine, but now, in the age of environments, it's still a really bad idea. > > Sure, PYTHONPATH was just an example. Environment variables are how > you configure Python in many wa

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-10 Thread Inada Naoki
On Wed, Feb 10, 2021 at 8:39 PM Paul Moore wrote: > > On Wed, 10 Feb 2021 at 11:01, Inada Naoki wrote: > > > > On Wed, Feb 10, 2021 at 5:33 PM Paul Moore wrote: > > > > > > So get PYTHONUTF8 added to the environment activate script. That's a > &g

[Python-ideas] Re: Make UTF-8 mode more accessible for Windows users.

2021-02-11 Thread Inada Naoki
-site ideas. Since its user environment variable, it won't break legacy applications running in a parent account. Does anyone against adding "Enable UTF-8 mode" in the Start menu? -- Inada Naoki ___ Python-ideas mailing list -- python

[Python-ideas] Re: dict.sort()?

2021-05-29 Thread Inada Naoki
FWI, this is a previous thread. https://discuss.python.org/t/add-a-dict-sort-method/5747 2021年5月30日(日) 1:57 Marco Sulla : > Since `dict` now is ordered, how about a `sort()` method? > It could have the same signature of list.sort(), with an optional > parameter "by" that can be "keys" or "values

[Python-ideas] Re: dict_items.__getitem__?

2021-10-04 Thread Inada Naoki
https://mail.python.org/archives/list/python-ideas@python.org/thread/QVTGZD6USSC34D4IJG76UPKZRXBBB4MM/ > but not this exact idea. What is difference between your idea and previsous discussion? -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.

[Python-ideas] Re: PEP 671 (late-bound arg defaults), next round of discussion!

2021-12-05 Thread Inada Naoki
than PEP 671. PEP 505 can be used for default parameters (e.g. `hi ??= len(a)`) and many other places. I feel it has far better benefit / language complexity ratio. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To un

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-16 Thread Inada Naoki
rozenset. So we can estimate how frozenset literal is useful by seeing how frozenset is used. Unless how the literal improve codes is demonstrated, I am -0.5 on new literal only for consistency. Regards, -- Inada Naoki ___ Python-ideas mailing list -

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-17 Thread Inada Naoki
should write `_TARGETS = frozenset((3, 5, 7, 11, 12, 18, 27, 28, 30, 35, 57, 88))` in global scope and use it as `if n in _TARGETS`. -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-id

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-17 Thread Inada Naoki
oposed literal might have significant efficiency benefit only when: * It is used in the function scope. and, * It can not be optimized by the compiler now. I am not sure how many such usages in stdlib. Regards, -- Inada Naoki ___ Python-ideas mail

[Python-ideas] Re: Revisiting a frozenset display literal

2022-01-17 Thread Inada Naoki
On Mon, Jan 17, 2022 at 8:49 PM Steven D'Aprano wrote: > > On Mon, Jan 17, 2022 at 08:04:50PM +0900, Inada Naoki wrote: > > > Name lookup is faster than building set in most case. > > So I don't think cost to look name up is important at all. > > But the cos

Re: [Python-ideas] Pre-conditions and post-conditions

2018-08-21 Thread INADA Naoki
n-typing-usage-of-annotations "With this in mind, uses for annotations incompatible with the aforementioned PEPs should be considered deprecated." -- INADA Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman

Re: [Python-ideas] Add "default" kwarg to list.pop()

2018-11-01 Thread INADA Naoki
remove the item. Unnecessary destructive change is bad. It reduces code readability, and it may create hard bug. If this proposal is adding `list.get([index[, default]])` too, I still -0. I don't know how often it is useful. Regards, -- INADA Naoki __

Re: [Python-ideas] Using sha512 instead of md5 on python.org/downloads

2018-12-07 Thread INADA Naoki
ck hash equality between formula and download site. If it's different, Homebrew or download site is under attack. So I think it's worth enough to moving to stronger and more used hash. (And by this reason, I prefer sha256 to sha512 for now.) -- INADA Naoki ___

Re: [Python-ideas] PEP 8 and long string literals

2019-02-25 Thread INADA Naoki
I think long URL in comment or docstring is good reason to ignore line length limit. But I'm not sure about general long string literals. -- INADA Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/lis

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread INADA Naoki
thon.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- INADA Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread INADA Naoki
On Fri, Mar 1, 2019 at 9:47 PM Chris Angelico wrote: > > On Fri, Mar 1, 2019 at 11:00 PM INADA Naoki wrote: > > > > I dislike adding more operator overload to builtin types. > > > > str is not commutative, but it satisfies a in (a+b), and b in (a+b). > > T

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread INADA Naoki
On Fri, Mar 1, 2019 at 10:10 PM Steven D'Aprano wrote: > > On Fri, Mar 01, 2019 at 08:59:45PM +0900, INADA Naoki wrote: > > I dislike adding more operator overload to builtin types. > > > > str is not commutative, but it satisfies a in (a+b), and b in (a+b). > >

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread INADA Naoki
t;a": 3} -- It seems bit curious compared with + of sequence, because [2]+[3] is not [5]. It looks like more Counter than container. * ValueError -- Hmm, it looks ugly to me. So I don't think "sum" is not fit to dict semantics. Regards, -- INADA Naoki __

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread INADA Naoki
quence and it seems hard to call it "sum". Regards, 2019年3月1日(金) 23:19 Ivan Levkivskyi : > On Fri, 1 Mar 2019 at 13:48, INADA Naoki wrote: > >> > >> > >> > Is that an invariant you expect to apply to other uses of the + >> > operator? &g

Re: [Python-ideas] Dict joining using + and +=

2019-03-01 Thread INADA Naoki
`seq + seq` in this point of view. I don't propose | than +. I just mean difference between dict.update() and seq+seq is not smaller than difference between dict.update() and set|set. If | seems not fit to this operation, + seems not fit to this operation too. -- INADA Naoki

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-01 Thread INADA Naoki
kwargs. I think non string keys are allowed for {**d1, **d2} by language. -- INADA Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-03 Thread INADA Naoki
s mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ -- INADA Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-04 Thread INADA Naoki
On Mon, Mar 4, 2019 at 6:52 PM Stefan Behnel wrote: > > I think the main intentions is to close a gap in the language. > > [1,2,3] + [4,5,6] > > works for lists and tuples, > > {1,2,3} | {4,5,6} > > works for sets, but joining two dicts isn't simply > > {1:2, 3:4} + {5:6} > Operators

Re: [Python-ideas] Dict joining using + and +=

2019-03-04 Thread INADA Naoki
ng new method to builtin should have a high bar. Adding new operator to builtin should have a higher bar. Adding new syntax should have a highest bar. -- INADA Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-04 Thread INADA Naoki
On Tue, Mar 5, 2019 at 12:02 AM Stefan Behnel wrote: > > INADA Naoki schrieb am 04.03.19 um 11:15: > > Why statement is not enough? > > I'm not sure I understand why you're asking this, but a statement is "not > enough" because it's a statement an

[Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-04 Thread INADA Naoki
updated()? sorted() is a function so it looks different from L.sort() But d.updated() is very similar to d.update() for human eyes. ## How about d1 - d2? If it is really useful, it can be implemented as method too. dict.discard(sequence_of_keys)

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-05 Thread INADA Naoki
On Tue, Mar 5, 2019 at 5:23 PM Chris Angelico wrote: > > On Tue, Mar 5, 2019 at 6:40 PM INADA Naoki wrote: > > This is why function and methods are better: > > > > * Easy to search. > > > > ## Merits of dict.merge() over operator + > > > > * Eas

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-05 Thread INADA Naoki
On Tue, Mar 5, 2019 at 5:50 PM Nathaniel Smith wrote: > > On Mon, Mar 4, 2019 at 11:41 PM INADA Naoki wrote: > > Then, I propose `dict.merge` method. It is outer-place version > > of `dict.update`, but accepts multiple dicts. (dict.update() > > can be updated to accept

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-05 Thread INADA Naoki
> * Type of returned value is always same to d1.copy(). No issubclass, > no __iadd__. I'm sorry, I meant __radd__, not __iadd__. ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct:

Re: [Python-ideas] Dict joining using + and +=

2019-03-05 Thread Inada Naoki
set too if it is added to dict for consistency. FWIW, Scala uses `++` for join all containers. Kotlin uses `+` for join all containers. (ref https://discuss.python.org/t/pep-584-survey-of-other-languages-operator-overload/977) Regards, -- Inada Naoki ___

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-05 Thread Inada Naoki
On Tue, Mar 5, 2019 at 7:26 PM Steven D'Aprano wrote: > > On Sat, Mar 02, 2019 at 01:47:37AM +0900, INADA Naoki wrote: > > > If the keys are not strings, it currently works in CPython, but it may > > > not work with other implementations, or future versions of CPyt

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-05 Thread Inada Naoki
On Tue, Mar 5, 2019 at 7:59 PM Steven D'Aprano wrote: > > On Tue, Mar 05, 2019 at 06:04:40PM +0900, INADA Naoki wrote: > [...] > > One obvious merit of d.merge(...) is it returns same type of d. > > `type(d1)(d1, d2)` looks ugly. > > > > But people just wan

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-05 Thread Inada Naoki
There was a thread for the topic. https://mail.python.org/pipermail/python-dev/2018-October/155435.html 2019年3月6日(水) 2:02 Anders Hovmöller : > > On a related note: **kwargs, should they support arbitrary strings as > keys? I depend on this behavior in production code and all python > implementa

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-06 Thread Inada Naoki
On Wed, Mar 6, 2019 at 5:34 PM Stefan Behnel wrote: > > INADA Naoki schrieb am 05.03.19 um 08:03:> On Tue, Mar 5, 2019 at 12:02 AM > Stefan Behnel wrote: > >> INADA Naoki schrieb am 04.03.19 um 11:15: > >>> Why statement is not enough? > >> > >&g

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-06 Thread Inada Naoki
th dict and think expressions like "d1 | d2" and "d1 & d2" would just be > confusing and misleading to encounter in the wild. Hmm. The PEP proposed dict - dict, which is similar to set - set (difference). To me, {"a": 1, "b": 2} - {"b":

Re: [Python-ideas] dict literal allows duplicate keys

2019-03-06 Thread Inada Naoki
as > in > > > > And as I recall, in SGML the first value "original" is the one that is > in effect. This is what happens with the LaTeX command > \providecommand. > > FURTHER LINKS > [6] https://docs.python.org/3/reference

Re: [Python-ideas] Why operators are useful

2019-03-15 Thread Inada Naoki
most natural to the container's type. That's what Kotlin and Scala does. (Although Scala used ++ instead of +). ref: https://discuss.python.org/t/pep-584-survey-of-other-languages-operator-overload/977 Regards, -- Inada Naoki ___ Python-ideas m

Re: [Python-ideas] dict.merge(d1, d2, ...) (Counter proposal for PEP 584)

2019-03-21 Thread Inada Naoki
pdated". > That would eliminate some of the difficulties with an operator, such as > the difference between + which requires both operands to be a dict > but += which can take any mapping or (key,value) iterable. > > -- > Steven -- Inada Naoki ___

Re: [Python-ideas] Allow not in lambda expressions

2019-03-26 Thread Inada Naoki
-2DD7-40BB-A1B8-4E2AA1F9FDF2> > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Inada Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] singledispatch for methods

2019-03-27 Thread Inada Naoki
ease try Python 3.8a3! https://docs.python.org/3.8/library/functools.html#functools.singledispatchmethod https://www.python.org/downloads/release/python-380a3/ -- Inada Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/m

Re: [Python-ideas] DB-API support for sets?

2019-05-22 Thread Inada Naoki
l library (like SQLAlchemy) provides better API for building query. Regards, -- Inada Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Implement POSIX ln via shutil.link and shutil.symlink

2019-06-04 Thread Inada Naoki
27;m weak +1 to implement this idiom directly in stdlib. tempfile.mkstemp doesn't support symlink. So people need to use external command `ln -sf` for now. Regards, -- Inada Naoki ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Inada Naoki
ython-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/FCTXGDT2NNKRJQ6CDEPWUXHVG2AAQZZY/ &g

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Inada Naoki
notations >>> def foo() -> int | str: ... pass ... >>> foo.__annotations__ {'return': 'int | str'} Please read PEP 563. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To uns

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-08-29 Thread Inada Naoki
plement runtime behavior for `str | int`. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-04 Thread Inada Naoki
... Mean +- std dev: 280 ns +- 8 ns $ python3 -m pyperf timeit -s 'x=[]; T=(str, list)' -- 'isinstance(x, T)' . Mean +- std dev: 73.1 ns +- 1.0 ns ``` Typing module doesn't have speedup extension. I expect`isinstance([], Union[str, list])` will be much

[Python-ideas] Re: Inspired by Scala, a new syntax for Union type

2019-09-04 Thread Inada Naoki
e is new way to do it but it may be much slower and use much memory, so you shouldn't use it unless you can ignore performance." Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to p

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-17 Thread Inada Naoki
ilman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/W2FCSC3JDA7NUBXAVSTVCUDEGAKWWPTH/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Inada Naoki _

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-19 Thread Inada Naoki
It looks + is the common way to merge two containers in some way. Shouldn't we add it to abc? So I think we shouldn't focus just adding `+` to dict. It comes with huge side effect. We should think about general API design of the (esp. builtin) containers. Rega

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-19 Thread Inada Naoki
first, or even remove unbound method from the PEP. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-20 Thread Inada Naoki
0 on + and +=, and -0 on doing nothing. > If we choose `+`, `+` is now "merging two containers", not just "concatenate two sequences". So it looks very inconsistent that set uses `|` instead of `+`. This inconsistency looks very ugly to me. How do you feel about this?

[Python-ideas] Re: PEP 584: Add + and += operators to the built-in dict class.

2019-10-23 Thread Inada Naoki
union is very natural to me. But if we use + for dict merging, I think we should add + to set too. Then the set has `.union()`, `|` and `+` for the same behavior. Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org T

[Python-ideas] Re: Sets for easy interning(?)

2019-12-02 Thread Inada Naoki
@python.org/message/T3Z32DEMWK46EBPULYB4CVI2QF4FS3WJ/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://ma

[Python-ideas] Re: Moving PEP 584 forward (dict + and += operators)

2019-12-03 Thread Inada Naoki
l.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/OYUGN5FOIQGEHS5XJFGHNLQO4AUJMUON/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Inada Naoki ___ Pyth

[Python-ideas] Recommend UTF-8 mode on Windows

2020-01-10 Thread Inada Naoki
cfg in the directory same to python.exe) to enable UTF-8 mode. But it may make Python startup process more complex... Regards, [1]: https://docs.microsoft.com/en-us/windows/uwp/design/globalizing/use-utf8-code-page [2]: https://docs.python.org/3/using/windows.html [3]: Currently, Python version

[Python-ideas] Re: Recommend UTF-8 mode on Windows

2020-01-11 Thread Inada Naoki
On Sat, Jan 11, 2020 at 2:30 AM Andrew Barnert wrote: > > On Jan 10, 2020, at 03:45, Inada Naoki wrote: > > > > Hi, all. > > > > I believe UTF-8 should be chosen by default for text encoding. > > Correct me if I’m wrong, but I think in Python 3.7 on Windo

[Python-ideas] Re: Recommend UTF-8 mode on Windows

2020-01-11 Thread Inada Naoki
x... > > I would definitely prefer to have a checkbox to configure "PYTHONUTF8" during > installation rather than requiring it to be done manually, assuming it can be > done safely and effectively across different systems. Not only for

[Python-ideas] Re: Recommend UTF-8 mode on Windows

2020-01-14 Thread Inada Naoki
UTF-8 mode doesn't break Mercurial. But I'm not sure. (Note that Mercurial on Python 3 on Windows is still beta.) Regards, -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-id

[Python-ideas] Re: List - append

2020-01-18 Thread Inada Naoki
On Sun, Jan 19, 2020 at 2:45 PM Siddharth Prajosh wrote: > > Moreover, shouldn't it work? > How do I add that feature in Python? How you can do it with warus operator. >>> (xs := list(range(10))).append(42) >>> xs [0, 1, 2, 3, 4, 5, 6, 7, 8, 9

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Inada Naoki
First of all, I am not so happy about typing is increasing Python runtime complexity. TypeScript is the most successful language with gradual typing. It has almost zero-cost about typing. It doesn't make JavaScript runtime complex. I hoped Python goes in same way. But Python went the different w

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Inada Naoki
On Sat, Mar 14, 2020 at 11:24 AM Inada Naoki wrote: > [snip] > a) Add `|` to all types. > b) Support it only statically (`from __future__ import annotations`). > [snip] > But (b) seems more consistent with PEP 560. > I'm sorry, I meant (a) looks more consistent with PE

[Python-ideas] Re: Allow using the or operator to denote unions in type annotations

2020-03-13 Thread Inada Naoki
On Sat, Mar 14, 2020 at 1:12 PM Inada Naoki wrote: > I'm sorry, I meant (a) looks more consistent with PEP 560. > Sorry again, I meant PEP 585, not PEP 560 as Guido explained already. -- Inada Naoki ___ Python-ideas mailing list -- p

[Python-ideas] PEP 597 -- Soft deprecation of omitting encoding

2020-05-03 Thread Inada Naoki
g unicode" ( https://bugs.python.org/issue37111) [3] Packaging tutorial in packaging.python.org didn't specify encoding to read a README.md (https://github.com/pypa/packaging.python.org/pull/682) [4] json.tool had used locale encoding to read JSON files. ( https://bugs.pytho

[Python-ideas] Re: Doc preview in Github PR

2020-06-16 Thread Inada Naoki
MH4M2JWPKA7B6GRLZHYD/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Inada Naoki ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/pyt

  1   2   3   >