Before the introduction of bool and also in other languages, `not not x` was/is
used to convert to True (1) and False (0). However, the old way is still much
faster than bool(x) or even operator.truth(x).
Test:
> py -3.10 -m timeit -s "objects = 1, 0, -0.0, "20", "False", 93, 28.569, [],
> set()
On Fri, Aug 6, 2021 at 5:31 PM wrote:
>
> Before the introduction of bool and also in other languages, `not not x`
> was/is used to convert to True (1) and False (0). However, the old way is
> still much faster than bool(x) or even operator.truth(x).
> Test:
> > py -3.10 -m timeit -s "objects =
I thought that many places in stdlib could be made faster by this (bool is used
a lot), maybe this is a major speedup.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.pyt
All good points. To me there is an elegance in being able to split the
different paths of the function into their own syntactically separate
function definitions.
One place where this excels is in handling happy paths vs error paths.
It increases clarity substantially, in my experience, to be able
Consider ML-style? :D
```
def fib(n):
| n == 0 = 0
| n == 1 = 1
| otherwise = fib(n-1) + fib(n-2)
def allow_entry(d):
| d == {"name": "Bob"} = "Bob is not allowed in ever!"
| d == {"name": "Charles", "day": "Tuesday"} = \
"It's a Tuesday, so Charles is allo
how does it compare with the old:
```
def rh(ham, _bool=bool):
return _bool(ham)
```
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-
On Fri, Aug 06, 2021 at 08:29:03AM -, [email protected] wrote:
> I thought that many places in stdlib could be made faster by this
> (bool is used a lot), maybe this is a major speedup.
I doubt that there are many places in the stdlib where the call to bool
is the bottleneck, and a micro-opti
06.08.21 10:29, [email protected] пише:
> Before the introduction of bool and also in other languages, `not not x`
> was/is used to convert to True (1) and False (0). However, the old way is
> still much faster than bool(x) or even operator.truth(x).
> Test:
>> py -3.10 -m timeit -s "objects = 1, 0
On Thu, Aug 05, 2021 at 09:39:44AM +0100, Sam Frances wrote:
> Following on from PEP 634, it would be good to be able to have Erlang /
> Elixir-style pattern matching in function headers.
This was recently discussed here:
https://mail.python.org/archives/list/[email protected]/message/ROYZ
On Fri, Aug 06, 2021 at 09:30:57AM +0100, Sam Frances wrote:
> All good points. To me there is an elegance in being able to split the
> different paths of the function into their own syntactically separate
> function definitions.
Do you use `functools.singledispatch`? Thatt gets you part-way ther
On Fri, Aug 06, 2021 at 04:17:55PM +0800, Mxzixl wrote:
> Consider ML-style? :D
>
> ```
>
> def fib(n):
> | n == 0 = 0
> | n == 1 = 1
> | otherwise = fib(n-1) + fib(n-2)
I like the look of this when I read Haskell code. We can bike-shed the
syntax, but I think that's more
On Fri, Aug 6, 2021 at 9:59 PM Steven D'Aprano wrote:
> > def fib(0):
> > return 0
> >
> > def fib(1):
> > return 1
> >
> > def fib(n):
> > return fib(n-1) + fib(n-2)
>
> I think that there is something rather disturbing about writing a
> function definition with a constant literal as
On 2021-08-06 at 21:57:47 +1000,
Steven D'Aprano wrote:
> On Thu, Aug 05, 2021 at 09:39:44AM +0100, Sam Frances wrote:
> > def fib(0):
> > return 0
> >
> > def fib(1):
> > return 1
> >
> > def fib(n):
> > return fib(n-1) + fib(n-2)
>
> I think that there is something rather distur
OpenAPI (https://spec.openapis.org/oas/latest.html) is an emerging standard for
defining RESTful interfaces.
OpenAPI is supported by swagger - which provides tools to convert an OpenAPI
spec into python code (for both backend as well as client).
The proposition I have is to make OpenAPI native t
You may want to take a look at FastAPI[1], it already does more or less
what you ask for.
There is no need for it to be part of the Python core, it's fine as it is
as a package.
[1] https://fastapi.tiangolo.com/
On Fri, 6 Aug 2021 at 17:39, Vaideeswaran Ganesan wrote:
> OpenAPI (https://spec.o
I looked at the fastapi code.
I actually want to avoid get, post, put, 2xx, 4xx codes in the client
portions of the code. (I don't think it's pythonic). And Fastapi seems to
have them exactly the same.
Look at how the code looks when you are using FastAPI and with my OpenAPI
Native Bindings - be
In your code example it looks like FastAPI is making 1 HTTP request vs.
your library is making 3 HTTP requests? Or are there some missing lines? Or
am I missing something?
Also are you referring to https://github.com/pyopenapi/pyopenapi ? And if
so what would be the reasoning to pull something lik
17 matches
Mail list logo