[issue43143] Allow multiple assignment (i.e. tuple on LHS) in walrus operator

2021-02-07 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Thanks. I would like to put this ticket in the context of other grammar-related tickets/elaboration for the assignment operator: https://bugs.python.org/issue42316 - allow foo[a:=1] instead of foo[(a:=1)] https://bugs.python.org/issue42374 - allow (c := i

[issue43143] Allow multiple assignment (i.e. tuple on LHS) in walrus operator

2021-02-07 Thread Paul Sokolovsky
Change by Paul Sokolovsky : -- nosy: +lys.nikolaou ___ Python tracker <https://bugs.python.org/issue43143> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43143] Allow multiple assignment (i.e. tuple on LHS) in walrus operator

2021-02-06 Thread Paul Sokolovsky
New submission from Paul Sokolovsky : Currently (CPython 3.10.0a4) having a tuple on left-hand side of assignment expression/operator (aka walrus operator) is not allowed: >>> ((a, b) := (1, 2)) File "", line 1 ((a, b) := (1, 2)) ^ SyntaxError: cannot use ass

[issue42729] tokenize, ast: No direct way to parse tokens into AST, a gap in the language processing pipiline

2020-12-24 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > the idea was proposed purely to "close a gap" That pinpoints it well. I was just writing a tutorial on implementing custom import hooks, with the idea to show people how easy it to do it in Python. As first step, I explained that it's bad i

[issue42729] tokenize, ast: No direct way to parse tokens into AST, a gap in the language processing pipiline

2020-12-24 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > There is a considerable tension on exposed parts of the compiler pipeline for > introspection and other capabilities and our ability to do optimizations. > Given how painful it has been in the past to deal with this, my view is to > av

[issue42729] tokenize, ast: No direct way to parse tokens into AST, a gap in the language processing pipiline

2020-12-24 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > but the thing I don't quite get is the use case. And if that went unanswered: the usecase, how I'd formulate it, is to not expose CPython historical implementation detail of "tokenize" being disconnected from the rest of the langua

[issue42729] tokenize, ast: No direct way to parse tokens into AST, a gap in the language processing pipiline

2020-12-24 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > What prevents you from using ast.parse(tokenize.untokenize(token_stream))? That's exactly the implementation in the patch now submitted against this issue. But that's the patch for CPython, the motive of the proposal here is to establish a standard

[issue42729] tokenize, ast: No direct way to parse tokens into AST, a gap in the language processing pipiline

2020-12-24 Thread Paul Sokolovsky
Change by Paul Sokolovsky : -- keywords: +patch pull_requests: +22773 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23922 ___ Python tracker <https://bugs.python.org/issu

[issue42729] tokenize, ast: No direct way to parse tokens into AST, a gap in the language processing pipiline

2020-12-24 Thread Paul Sokolovsky
New submission from Paul Sokolovsky : Currently, it's possible: * To get from stream-of-characters program representation to AST representation (AST.parse()). * To get from AST to code object (compile()). * To get from a code object to first-class function to the execute the program. Python

[issue42559] random.getrandbits: Should it be explicit that it returns unsigned/non-negative integer?

2020-12-07 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Raymond Hettinger: Thanks for acking it would be a useful change! ZackerySpytz: Thanks for making a patch! -- ___ Python tracker <https://bugs.python.org/issue42

[issue42559] random.getrandbits: Should it be explicit that it returns unsigned/non-negative integer?

2020-12-03 Thread Paul Sokolovsky
New submission from Paul Sokolovsky : Current docs for random.getrandbits() ( https://docs.python.org/3/library/random.html#random.getrandbits ) read (3.9.1rc1 at the top of the page): Returns a Python integer with k random bits. This method is supplied with the MersenneTwister generator

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-17 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > We may be possible to replace bytecode from `STORE_GLOBAL _cnt; LOAD_GLOBAL > _cnt` into `DUP_TOP; STORE_GLOBAL _cnt`. Sounds good, and that's why I personally care about the "STORE" case, and the patch I submit touches only it, which w

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-17 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Absolutely should be able to optimize namespace access. The fact that namespace is a dict is an implementation detail, it's still inefficient even with all those version counters and inline caches. Ironically, to let people prototype better, more efficient

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > exec() function is currently quite clear A recent case: https://bugs.python.org/issue38316, co_stacksize was quite clear what it is. Turned out, a bug in the documentation (likely, just someone forgot to update it to the actual code). That's just

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > Namespace performances are really critical for overall Python performances. Yeah, that's why I'd like for myself and other people to make it easy to explore the behavior of namespace lookups, to see how to optimize them. > You're free to fork

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > Paul: you're are in front of 3 core developers who are rejecting your feature > request. But no, it's not my feature request. There were 2 tickets by at least 2 people. I just saw my case to be similar to cases of those people, so instead of cr

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > you ask to modify Python so you can pass dict subclasses as namespaces and > expect CPython to respect the mapping protocol But no, per your own account, you made noticeable, though not complete, code changes in that direction. The only thing I'm

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Ok, so the patch for my usecase (STORE_GLOBAL) is vividly trivial, so to go thru the full circle, I posted it: https://github.com/python/cpython/pull/18033 . -- ___ Python tracker <https://bugs.python.

[issue36220] LOAD_NAME and LOAD_GLOBAL, STORE_GLOBAL handle dict subclasses for globals() differently

2020-01-16 Thread Paul Sokolovsky
Change by Paul Sokolovsky : -- pull_requests: +17429 pull_request: https://github.com/python/cpython/pull/18033 ___ Python tracker <https://bugs.python.org/issue36

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: s/only our own usecase/only your own usecase/ (missing "y" typo) -- ___ Python tracker <https://bugs.python.o

[issue32615] Inconsistent behavior if globals is a dict subclass

2020-01-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > Later, I closed my pysandbox beause it was "broken by design": https://lwn.net/Articles/574215/ Thanks for the link, insightful. Still unclear, by design of what it's broken ;-). > Paul Sokolovsky wrote in bpo-36220 than his idea is a

[issue32615] Inconsistent behavior if globals is a dict subclass

2019-12-30 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > I agree with Terry, the moment you pass a dict subclass to exec you are out > of contract. If any, we may need to sanitize the input to exec, although I > don't think is worth paying the performance price for that. exec() params are alread

[issue32615] Inconsistent behavior if globals is a dict subclass

2019-12-30 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > The doc for exec says globals "must be a dictionary (and not a subclass of > dictionary)" Docs are full of mistakes and outdated information. Fixing STORE_GLOBAL case from https://bugs.python.org/issue36220#msg359046 would be triv

[issue32615] Inconsistent behavior if globals is a dict subclass

2019-12-30 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Some smart maintainer closed https://bugs.python.org/issue36220 as a duplicate of this one. That ticket might have more details of the underlying issues. -- nosy: +pfalcon ___ Python tracker <ht

[issue36220] LOAD_NAME and LOAD_GLOBAL, STORE_GLOBAL handle dict subclasses for globals() differently

2019-12-30 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: > I wanted to write a sandbox for Python. Sandbox indeed, it is. class NS(dict): def __setitem__(self, k, v): if not isinstance(v, type(lambda: 0)): raise RuntimeError("Global variables considered harmful") globals

[issue36220] LOAD_NAME and LOAD_GLOBAL, STORE_GLOBAL handle dict subclasses for globals() differently

2019-12-30 Thread Paul Sokolovsky
Change by Paul Sokolovsky : -- nosy: +pfalcon title: LOAD_NAME and LOAD_GLOBAL handle dict subclasses for globals() differently -> LOAD_NAME and LOAD_GLOBAL, STORE_GLOBAL handle dict subclasses for globals() differently ___ Python tracker <

[issue38316] docs: Code object's "co_stacksize" field is described with mistake

2019-09-29 Thread Paul Sokolovsky
New submission from Paul Sokolovsky : CPython's Data Model -> Internal types -> Code objects, direct link as of version 3.7 is: https://docs.python.org/3.7/reference/datamodel.html?highlight=co_stacksize#index-55 , states following: * "co_nlocals is the number of local var

[issue12345] Add math.tau

2016-08-12 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: What about rounding pi to 3 (and tau to 6)? https://en.wikipedia.org/wiki/Indiana_Pi_Bill (and I'm sure we can find a cute video about how cool to have pi as 3 to add it to the docs). -- nosy: +pfalcon ___ Python

[issue26899] struct.pack_into(), struct.unpack_from() don't document support for negative offsets

2016-05-01 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: See https://docs.python.org/3/library/struct.html#struct.pack_into https://docs.python.org/3/library/struct.html#struct.unpack_from Actual source contains code like: if (offset < 0) offset += vbuf.len; to allow specify offsets from the

[issue1103213] Adding a recvexactly() to socket.socket: receive exactly n bytes

2016-04-08 Thread Paul Sokolovsky
Changes by Paul Sokolovsky <pfal...@users.sourceforge.net>: -- nosy: +pfalcon ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.o

[issue24449] Please add async write method to asyncio.StreamWriter

2015-06-15 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Thanks for the response. and an API with more choices is not necessarily better. I certainly agree, and that's why I try to implement MicroPython's uasyncio solely in terms of coroutines, without Futures and Transports. But I of course can't argue

[issue24449] Please add async write method to asyncio.StreamWriter

2015-06-14 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: This issue was brought is somewhat sporadic manner on python-tulip mailing list, hence this ticket. The discussion on the ML: https://groups.google.com/d/msg/python-tulip/JA0-FC_pliA/knMvVGxp2WsJ (all other messages below threaded from this) https

[issue24449] Please add async write method to asyncio.StreamWriter

2015-06-14 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: No, I haven't brought this many times before. Discussion on the mailing list last week was first time I brought up *this* issue. But it's indeed not the first time I provide feedback regarding various aspects of asyncio, so I wonder if this issue was closed

[issue23702] docs.python.org/3/howto/descriptor.html still refers to unbound methods

2015-03-18 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: Under https://docs.python.org/3/howto/descriptor.html#functions-and-methods , there're several references to unbound methods (including in expected output from the interpreter). As known, unbound methods are gone in Python3, so seeing those are confusing

[issue21511] Thinko in Lib/quopri.py

2014-05-16 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: This is minor issue indeed, uncovered when trying to run quopri.py with MicroPython http://micropython.org . I now worked around this on MicroPython side, but otherwise I set to report any issues I've seen with MicroPython porting, in the hope

[issue21511] Thinko in Lib/quopri.py

2014-05-15 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: Lib/quopri.py for version 3.3..3.5-tip contains following code: ESCAPE = b'=' ... line = input.readline() if not line: break i, n = 0, len(line) if n 0 and line[n-1:n] == b'\n': ... elif i+1 n and line[i+1

[issue21464] fnmatch module uses regular expression with undefined result to perform matching

2014-05-10 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: I see, so it's my misreading of the re module docs. I kinda thought that x in (?x) means any single-character flag of set (?aiLmsux). I was wrong, it is the specific literal flag. Also, rereading it again, the doc says the letters set the corresponding

[issue21464] fnmatch module uses undefined regular expression to perform matching

2014-05-09 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: fnmatch.translate() ends with: return res + '\Z(?ms)' However, https://docs.python.org/3.4/library/re.html#regular-expression-syntax states: Note that the (?x) flag changes how the expression is parsed. It should be used first in the expression string

[issue21464] fnmatch module uses regular expression with undefined result to perform matching

2014-05-09 Thread Paul Sokolovsky
Changes by Paul Sokolovsky pfal...@users.sourceforge.net: -- title: fnmatch module uses undefined regular expression to perform matching - fnmatch module uses regular expression with undefined result to perform matching ___ Python tracker rep

[issue21365] asyncio.Task reference misses the most important fact about it, related info spread around intros and example commentary instead

2014-04-27 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: It caused me a big surprise that asyncio.Task object automatically schedules itself in the main loop for execution upon creation (i.e. in constructor). Nowhere in the main reference part of section 18.5.2.4. Task (https://docs.python.org/3.5/library

[issue21365] asyncio.Task reference misses the most important fact about it, related info spread around intros and example commentary instead

2014-04-27 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Based on discussion https://groups.google.com/forum/#!topic/python-tulip/zfMQIUcIR-0 . That discussion actually questions the grounds of such Task behavior, and points it as a violation of Explicit is better than implicit principle, and as inconsistent

[issue21180] Cannot efficiently create empty array.array of given size, inconsistency with bytearray

2014-04-13 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: array.array('i', [0]) * 3 @Serhiy Storchaka: The keyword is efficiently. Let's analyze: this creates useless array.array('i', [0]) object destined only for garbage collection. Then, it forces using loop of loops to fill in a new object. Whereas

[issue21180] Cannot efficiently create empty array.array of given size, inconsistency with bytearray

2014-04-13 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: @Terry J. Reedy: Thanks for the pointer. My inital response is sadness, another bloating of namespace. But I'm adjusting. But that PEP shows the issue with all that activity: CPython stdlib got so big and bloated, that it lives its own life and people

[issue21180] Cannot efficiently create empty array.array of given size, inconsistency with bytearray

2014-04-13 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Martin: People might expect that array.array('i', 3) creates an array with the single value 3. I don't know which people would expect that. Personally I recognize the need to create an empty array of of given size, and have read the docs for builtin

[issue17145] memoryview(array.array)

2014-04-08 Thread Paul Sokolovsky
Changes by Paul Sokolovsky pfal...@users.sourceforge.net: -- nosy: +pfalcon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17145 ___ ___ Python

[issue21180] Cannot efficiently create empty array.array of given size, inconsistency with bytearray

2014-04-08 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: With bytearray, you can do: bytearray(3) bytearray(b'\x00\x00\x00') However, with arrays: array.array('i', 3) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'int' object is not iterable Given that int passed as seconf

[issue9066] Standard type codes for array.array, same as struct

2014-04-08 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: It's not clear to me that importing specifier prefixes from the struct module is the best way to go about this, though. What are other alternatives then? Using struct's syntax has obvious benefit of being consistent and not confusing people any further

[issue9066] Standard type codes for array.array, same as struct

2014-04-08 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: See also http://bugs.python.org/issue17345 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9066 ___ ___ Python

[issue17345] Portable and extended type specifiers for array module

2014-04-08 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: See also http://bugs.python.org/issue9066 -- nosy: +pfalcon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17345

[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3

2014-02-02 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: The problem with pystone is that such tool is used to compare performances between different versions of Python. That's why I just propose to switch it to time.time(), which surely is available on each and every Python version and implementation

[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3

2014-02-02 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: Yes, and my note about scientificity above. Also compare with your own account of time.perf_counter() above (Usually time.perf_counter() is the expected function.) Also, I didn't want to start discussion on how to do benchmarking right, just to point out

[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3

2014-02-01 Thread Paul Sokolovsky
New submission from Paul Sokolovsky: http://docs.python.org/3.3/library/time.html#time.clock says that it's deprecated, but pystone.py in Python-3.4.0b3 tarball still uses it. Please kindly consider switching it to plain time.time() and not to some other novelties. My usecase is: I'm

[issue20475] pystone.py in 3.4 still uses time.clock(), even though it's marked as deprecated since 3.3

2014-02-01 Thread Paul Sokolovsky
Changes by Paul Sokolovsky pfal...@users.sourceforge.net: -- components: +Benchmarks versions: +Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20475

[issue1346238] A constant folding optimization pass for the AST

2013-12-31 Thread Paul Sokolovsky
Paul Sokolovsky added the comment: 8 years after the original patch, there's still no trivial constant folding in bytecode generated (because peephole of course is not a real optimizer to consistently catch all cases): $ cat const.py FOO = 1 BAR = FOO + 2 + 4 $ python --version Python 2.7.3

[issue10203] sqlite3.Row doesn't support sequence protocol

2010-10-26 Thread Paul Sokolovsky
New submission from Paul Sokolovsky pfal...@users.sourceforge.net: sqlite.Row class doesn't implement sequence protocol, which is rather unfortunate, because it is described and expected to work like a tuple, with extra mapping-like functionality. Specific issue I hit: Adding rows to PyGTK

[issue10203] sqlite3.Row doesn't support sequence protocol

2010-10-26 Thread Paul Sokolovsky
Changes by Paul Sokolovsky pfal...@users.sourceforge.net: -- versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10203