Run tracemalloc module as a script
It would be useful to have the ability to invoke tracemalloc as a script for tracing memory allocations in another script. For example: python -m tracemalloc [-o output_file] [-t key_type]...
View ArticleDon't forbid `map(nullary_func)`
map(f, *iterables) calls f with elements from the iterables until one of them runs out of elements. Except when there are zero iterables. That’s forbidden, for no apparent reason. With the above...
View ArticleAsyncio Semaphore with support for priorities
Brief Asyncio semaphores are commonly used in scenarios where resources are constrained or valuable, such as managing database connections, making API calls, or conducting AI model inference....
View ArticleAdd a character subclass of str
Python doesn’t have a builtin type for 1 character strings (chars). This makes it impossible to declare this in function definitions: def ord(char: str, /) -> int: if len(char) != 1: raise...
View ArticleShorter and reversed format for traceback
Current traceback seems optimized for terminal. See this example. Source code Output from traceback.print_exception(e): Traceback (most recent call last): File...
View ArticleImproving collection of stable ABI macros and inline functions
A few weeks ago, I (unexpectedly) started a thread on whether Py_XDECREF and its siblings are part of the limited API/stable ABI despite it not being listed in the stable_abi.toml (TL,DR: They are.)....
View ArticleDataclasses - Sentinel to Stop creating "Field" instances
I was wondering whether the following would be a good idea from dataclasses import dataclass, field, KW_ONLY, NO_FIELD @dataclass class Example: a: bool = True _: KW_ONLY kw_a: bool: = False b: str =...
View ArticleItertools.tee should retain StopIteration value
I am remaking my original question as a suggestion here since it seems like there isn’t any immediately obvious reason against it. itertools.tee “copies” an iterator. Part of the iterator protocol is...
View ArticleIs name mangling still still the best way to best, the only way and the...
Name mangling has been the answer to the protection of private instance variables so far. However, is it still the best, the only way and the future to protect the private instance variables? I have...
View ArticleCommand-line interface for the `random` module
Many stdlib libraries have a simple CLI: Modules command-line interface (CLI) — Python 3.12.3 documentation Some of my favourites: $ python3 -m http.server Serving HTTP on :: port 8000...
View ArticlePython and OpenSSL FIPS mode
Hi folks, I’d like to start a discussion regarding CPython’s compatibility with OpenSSL’s FIPS mode. FIPS-140 is a set of security standards for cryptographic modules, mainly used in US Federal...
View ArticleAdd Symmetric Difference Operators To Dict
Hello Python community, Following the introduction of dictionary merging and updating operations (| and |=) in PEP 584, I am proposing the addition of symmetric difference operations for dictionaries....
View ArticleAdding a low level wait for file descriptor
I had to integrate using asyncio a blocking library that uses sockets. Typical use case: async def handler(fd): loop = asyncio.get_running_loop() while True: await loop.wait_readable(fd) x =...
View ArticleAdd os.path.splitanchor()
Sometimes you need just the anchor of a path (the concatenation of drive & root). But currently, this is a bit clunky: drive, root, _ = splitroot(path) anchor = drive + root This would be easier...
View ArticleFile path support for pickle.dump and pickle.load
I’ve been using the pickle library for sometime (mainly the dump and load functions to write python objects into filesystem). I have an idea that may be useful for developers (like me and many...
View ArticleNew math.floor() parameter
Hi. I suggest a new parameter for the math.floor() function so we can specify the location. Example: a = 547.193 math.floor(a) -> 547 math.floor(a, 1) -> 547.1 math.floor(a, 2) -> 547.19...
View ArticleAdd Difference Operators To Dict
Hello community Following the previous discussion that I started, I thought and came to several conclusions - the desire to add the operators -, -= to the dictionary in Python. I’m Looking for...
View ArticleDefault dictionary syntax
Hi. I suggest a default syntax to define dictionary. Example: d1 = {'a':1, 'b':None, 'c':None} d2 = {'a':1, 'b', 'c'} d1 == d2 If key:value pair exists then it wont be set. In addition to this, I...
View ArticleAdd additional options for the tkinter's PhotoImage copy method
Right now, the PhotoImage copy method looks like this: # XXX copy -from, -to, ...? def copy(self): """Return a new PhotoImage with the same image as this widget.""" destImage =...
View ArticleUse PyCapsule_* for the _sqlite3 c extension
I have an idea for a C extension module of mine, however it would require access to the api’s in the _sqlite3 c extension itself. I notice how easy it is to access the api in the “datetime” module via...
View ArticleAdd an option to http for socket protocol selection
Currently, the http module can only use TCP sockets. But since 3.10 IPPROTO_MPTCP is supported. It would be nice to be able to select it when using the http lib. For the http.client, a new optionnal...
View ArticleNwise itertools
github.com/python/cpython gh-118179: Added implementation for nwise to itertools python:main ← lsproule:nwise opened 09:02PM - 22 Apr 24 UTC lsproule +194 -1 <!-- Thanks for your contribution!...
View ArticleAOT instead of JIT
Hi, as many of you have heard, there is an ongoing effort to add JIT to CPython as PEP 744 (PEP 744 – JIT Compilation | peps.python.org). I think that the recent efforts to make Python faster have...
View ArticleOverload generators / generator operators
Hi, I would like to overload the Generator class, or maybe it would be even better to add operations to generators. For instance imagine I want the sum of two generators where one has a delay. def...
View ArticleShould `patch` propagate `__doc__` when `autospec=True`
I have observed when using unittest.mock.patch with autospec=True that __doc__ is not propagated, but __name__ is. from unittest.mock import patch def some_function() -> None: """Some docstring."""...
View Article
More Pages to Explore .....