I was trying to google if there were some attempts to add pattern
matching feature (as seen in e.g. haskell) to Python. I couldn't however
find anything. Were there any proposals for a feature like this?
On Sun, Apr 5, 2015, at 00:00, Steven D'Aprano wrote:
> As I understand it, the list of codes accepted is platform-dependent.
> While many codes are standard from machine to machine, some are not
> available on some systems.
In my opinion all codes accepted by C11 *should* be supported by python;
its present failure to do so is a wart. Any new work to address this
issue should be in the form of a pure python strftime function rather
than an effort to document every platform's idiosyncracies.
In particular, none of the specifiers in the standard _except_ %z or %Z
require any platform-specific logic. And these could be addressed by
likewise supporting tm_zone and tm_gmtoff on platforms that do not
There are a lot of implicit caches in the stdlib. Some of them can grow
unlimitedly. It would be good to have an official way to clear caches.
I proposed to add two functions (in some existing lightweight module or
add a new module):
clear_caches() calls cache clearing functions for specified level and
register_cache() registers cache clearing functions for specified level.
All modules that use implicit cache should register clearing function.
functools.lru_cache() should register wrapper's cache clearing function.
May be register gc.collect too. Third-party libraries and user code will
be able to register their own clearing functions.
Attached is a new module loader I've been working on that's an order of
magnitude times faster than the current one. What would it take for this to
(rot13) Ncevy Sbbyf!
[ERROR]: Your autotools build scripts are 200 lines longer than your
program. Something’s wrong.
I want Python to have macros. This is obviously a hard sell. I'm willing
to do some legwork to demonstrate value.
What would a good proposal include? Are there good examples of failed
proposals on this topic?
Is the core team open to this topic?
Thank you for your time,
- Mathew Rocklin
Sometimes we need a simple class to hold some mutable attributes,
provide a nice repr, support == for testing, and support iterable
unpacking, so you can write:
>>> p = Point(3, 4)
>>> x, y = p
That's very much like the classes built by namedtuple, but mutable.
I propose we add to the collections module another class factory. I am
calling it plainclass, but perhaps we can think of a better name. Here
is how it would be used:
>>> import collections
>>> Point = collections.plainclass('Point', 'x y')
The signature of the plainclass function would be exactly the same as
namedtuple, supporting the same alternative ways of naming the
The semantics of the generated Point class would be like this code:
What do you think?
PS. I am aware that there are "Namespace" classes in the standard
library (e.g. ). They solve a different problem.
| Author of Fluent Python (O'Reilly, 2015)
| Professor em: http://python.pro.br
| Twitter: @ramalhoorg