Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
PEP 681 -- Data Class Transforms PEP:681 Title:Data Class Transforms Author:Erik De Bonte <erikd at microsoft.com>, Eric Traut <erictr at microsoft.com> Sponsor:Jelle Zijlstra <jelle.zijlstra at gmail.com> Discussions-To:https://mail.python.org/archives/list/typing-sig@python.org/thread/EAALIHA3XEDFDNG2NRXTI3ERFPAD65Z4/ Status:Draft Type:Standards Track Created:02-Dec-2021 Python-Version:3.11 Post-History: Contents Abstract Motivation Rationale Specificatio...
...constant would be very close to introducing a new Missing value-level constant at runtime, creating a second null-like runtime value in addition to None. Having two different null-like constants in Python (None and Missing) would be confusing. Many newcomers to JavaScript already have difficulty distinguishing between its analogous constants null and undefined. Replace Optional with Nullable. Repurpose Optional to mean “optional item”. Optional[] is too ubiquitous to deprecate, although use o...
...constants and documenting them as constants in a checkable way. Creating a read-only attribute that may not be overridden by subclasses. (@property can make an attribute read-only but does not prevent overriding) Allowing a name to be used in situations where ordinarily a literal is expected (for example as a field name for NamedTuple, a tuple of types passed to isinstance, or an argument to a function with arguments of Literal type (PEP 586)). Specification The final decorator The typing.f...
...Constants in the Standard Library PEP:329 Title:Treating Builtins as Constants in the Standard Library Author:Raymond Hettinger <python at rcn.com> Status:Rejected Type:Standards Track Created:18-Apr-2004 Python-Version:2.4 Post-History:18-Apr-2004 Contents Abstract Status Motivation Proposal Questions and Answers Sample Implementation References Copyright Abstract The proposal is to add a function for treating builtin references as constants and to apply that functio...
...constants in this file are now in the 'termios' module. Date: 10-Aug-2004 Documentation: This module has been documented as obsolete since Python 2.1, but listing in this PEP was neglected. Removed from the library reference in Python 2.4. Module name: statcache Rationale: Using the cache can be fragile and error-prone; applications should just use os.stat() directly. Date: 10-Aug-2004 Documentation: This module has been docum...
...constants. A proposed rule to use a leading dot (e.g. .CONSTANT) for that purpose was criticised because it was felt that the dot would not be a visible-enough marker for that purpose. Partly inspired by forms found in other programming languages, a number of different markers/sigils were proposed (such as ^CONSTANT, $CONSTANT, ==CONSTANT, CONSTANT?, or the word enclosed in backticks), although there was no obvious or natural choice. The current proposal therefore leaves the discussion and pos...
...constants": they aren't really immutable, since anyone can still assign to the name. There are existing idioms for avoiding mutable default values. The potential of optimizing code using frozendict in PyPy is unsure; a lot of other things would have to change first. The same holds for compile-time lookups in general. Multiple threads can agree by convention not to mutate a shared dict, there's no great need for enforcement. Multiple processes can't share dicts. Adding a security sandbox writte...
...constants "false" and "true", in all lowercase. For Python, I prefer to stick with the example set by the existing built-in constants, which all use CapitalizedWords: None, Ellipsis, NotImplemented (as well as all built-in exceptions). Python's built-in namespace uses all lowercase for functions and types only. It has been suggested that, in order to satisfy user expectations, for every x that is considered true in a Boolean context, the expression x == True should be true, and likewise if x ...
...declaration. Indented lines below the function declaration declare parameters, one per line; lines below those that are indented even further are per-parameter docstrings. Finally, the first line dedented back to column 0 end parameter declarations and start the function docstring. Parameter docstrings are optional; function docstrings are not. Functions that specify no arguments may simply specify the function declaration followed by the docstring. Module and Class Declarations When a C fil...
...constants See also optimizations implemented in fatoptimizer, a static optimizer for Python 3.6. The following issues can be implemented with an AST optimizer: Issue #1346238: A constant folding optimization pass for the AST Issue #2181: optimize out local variables at end of function Issue #2499: Fold unary + and not on constants Issue #4264: Patch: optimize code to use LIST_APPEND instead of calling list.append Issue #7682: Optimisation of if with constant expression Issue #10399: AST Optimi...
...declaration might be removed from public header files but kept in the library. This is currently a possibility for the future; this PEP does not to propose a concrete process for deprecations and removals. The goal for the Limited API is to cover everything needed to interact with the interpreter. The main reason to not include a public API in the Limited subset should be that it needs implementation details that change between CPython versions (like struct memory layouts) – usually for perform...
...declaration of "static" type objects is not possible anymore (for applications using this ABI). Instead, type objects get created dynamically. To allow an easy creation of types (in particular, to be able to fill out function pointers easily), the following structures and functions are available: typedef struct{ int slot; /* slot id, see below */ void *pfunc; /* function pointer */ } PyType_Slot; typedef struct{ const char* name; int basicsize; int itemsize; unsigned int flags; ...
...Constants Constants are usually defined on a module level and written in all capital letters with underscores separating words. Examples include MAX_OVERFLOW and TOTAL. Designing for Inheritance Always decide whether a class's methods and instance variables (collectively: "attributes") should be public or non-public. If in doubt, choose non-public; it's easier to make it public later than to make a public attribute non-public. Public attributes are those that you expect unrelated clients of ...
...constants with a leading minus sign would come out with the wrong sign. ("Unsigned" hex/oct constants are those with a face value in the range sys.maxint+1 through sys.maxint*2+1, inclusive; these have always been interpreted as negative numbers through sign folding.) E.g. 0xffffffff is -1, and -(0xffffffff) is 1, but -0xffffffff would come out as -4294967295. This was the case in Python 2.2 through 2.2.2 and 2.3a1, and in Python 2.4 it will once again have that value, but according t...
...constants into a single constant. SF bug #513866: Float/long comparison anomaly. Prior to 2.4b1, when an integer was compared to a float, the integer was coerced to a float. That could yield spurious overflow errors (if the integer was very large), and to anomalies such as long(1e200)+1 == 1e200 == long(1e200)-1. Coercion to float is no longer performed, and cases like long(1e200)-1 < 1e200, long(1e200)+1 > 1e200 and (1 << 20000) > 1e200 are computed correctly now. Extension...
...constants; for example _ssl has a long list of calls in the form: PyModule_AddIntConstant(m, "SSL_ERROR_ZERO_RETURN", PY_SSL_ERROR_ZERO_RETURN); Converting this to a declarative list, similar to PyMethodDef, would reduce boilerplate, and provide free error-checking which is often missing. String constants and types can be handled similarly. (Note that non-default bases for types cannot be portably specified statically; this case would need a Py_mod_exec function that ru...
...constantly reinventing the wheel. He feels that Python's core development community is great, but we need to open it up a little bit more to get more involvement and try to rally the community regarding large-scale development. S. Deibel noted that some people strongly want python.org to showcase "best of breed" projects, and others want python.org to avoid favoring specific projects. M. von Löwis suggested that we get the web framework authors interested in python.org (offer hosting,...
...Constantly working on ledger items and payment instructions for KBK. Working on the budget to make sure it is as accurate as possible. This includes misc costs, F&B, AV, hotel, commissions, financial aid, etc. Collecting all final bills and making sure they are correct before they are placed in the ledger for payment. PyCon Catering Finalized PyCon 2013 catering. PyCon Contract Negotiations Nothing to report for February & March PyCon Electrical Finalized the electrical...
...declarations - you can put a comment of the form "# -- coding: <encodingname> --" in the first or second line of a Python source file to indicate the encoding (e.g. utf-8). (PEP 263 phase 1) Codec error handling callbacks - this allows for flexible handling of encoding errors. (PEP 293) File objects are now their own iterators. This makes multiple interrupted iterations over the same file more reliable. The xreadlines() method and module are now deprecated. The in operator ca...
...declarations similar to C structs. This could be useful, for example, for future ctypes releases as well as ORMs that define database tables as classes, like the one the Django framework ships. Django currently uses an ugly hack to restore the ordering of members in database models. The RawConfigParser class accepts a dict_type argument that allows an application to set the type of dictionary used internally. The motivation for this addition was expressly to allow users to provide an ordered d...