On Sun, 20 Jun 2021 at 23:29, Greg Ewing wrote:
>
> On 21/06/21 6:04 am, Sebastian Berg wrote:
> > * `flatten()` (alwasy copy)
> > * `ravel()` (copies if needed, and additionally ensures contiguity)
> > * `reshape(-1)` (copies if needed)
> >
> > They are all subtly different, unfortunately.
>
> Th
Your assumption about requiring some form of registration system for Python to
implement extensions is correct as Roslyn (The C# compiler) resolves them at
compile time (as long as the namespace is imported/the class is in the "global"
namespace)
When I said static function, it's basically me s
Hi William,
Thanks for the description of C# extension methods, but I think that
like Britons and Americans, we're in danger of being divided by a common
language. (To paraphrase Churchill.)
On Sun, Jun 20, 2021 at 10:56:37PM -, William Pickard wrote:
> While IDK about Kotlin's extension m
On 2021-06-20 7:48 p.m., Steven D'Aprano wrote:
> The technique you are calling "extension methods" is known as
> "monkey-patching" in Python and Ruby.
>
> With respect to a fine language, Kotlin, it doesn't have the user-base
> of either Python or Ruby. Python does not allow monkey-patching b
While IDK about Kotlin's extension methods, I do know that C# (A highly popular
programming language) also has extension methods so I'll talk about those.
In C#, extension methods are plain static functions defined in a plain static
class, the only key difference between normal static methods an
The technique you are calling "extension methods" is known as
"monkey-patching" in Python and Ruby.
With respect to a fine language, Kotlin, it doesn't have the user-base
of either Python or Ruby. Python does not allow monkey-patching builtin
classes, but Ruby does:
https://avdi.codes/why-monk
On 21/06/21 6:04 am, Sebastian Berg wrote:
* `flatten()` (alwasy copy)
* `ravel()` (copies if needed, and additionally ensures contiguity)
* `reshape(-1)` (copies if needed)
They are all subtly different, unfortunately.
There's also a .flat attribute, that returns a 1-d iterator!
--
Greg
With normal synchronous code you can use `contextvars.Context.run()` to change
what context code is executing within. However, there is no analagous concept
for asyncio code. I'm proposing something similar, for example:
coro = foo()
my_context = convextvars.Context()
await asyncio.run_in_contex
On Sun, Jun 20, 2021, 2:07 PM Sebastian Berg
> NumPy has:
>
> * `flatten()` (always copy)
> * `ravel()` (copies if needed, and additionally ensures contiguity)
> * `reshape(-1)` (copies if needed)
>
> They are all subtly different, unfortunately.
>
Oops! Sebastian is right, and I made an error. N
On Sun, 2021-06-20 at 13:48 -0400, David Mertz wrote:
> On Sun, Jun 20, 2021 at 1:07 PM Christopher Barker <
> python...@gmail.com>
> wrote:
>
> > Flatten is used in numpy:
> > Where it is a method, and goes all the way to one dimension.
> >
>
> I think it's worth keeping in mind the differences
On Sun, Jun 20, 2021 at 1:07 PM Christopher Barker
wrote:
> Flatten is used in numpy:
> Where it is a method, and goes all the way to one dimension.
>
I think it's worth keeping in mind the differences though. In NumPy,
arr.flatten() doesn't even TOUCH the array itself. It is solely a
manipula
Flatten is used in numpy:
https://numpy.org/doc/stable/reference/generated/numpy.ndarray.flatten.html?highlight=flatten#numpy.ndarray.flatten
Where it is a method, and goes all the way to one dimension.
A builtin flatten can’t be the same, but it would be nice if it weren’t too
different. e.g. l
On 2021-06-20 at 12:18:24 -,
Johan Vergeer wrote:
> After working with Kotlin for a while I really started to like the
> idea of extension methods. I delivers a great way to extend the
> language without having to add features to the language itself.
I disagree with the premise that such a t
What objection do you have to creating a subclass?
Adding methods to e.g. list could give you problems if you import 2
modules that each modify list and the modifications are incompatible.
It could conceivably add bugs to code that uses list in a standard way.
Best wishes
Rob Cliffe
On 20/06/
After working with Kotlin for a while I really started to like the idea of
extension methods. I delivers a great way to extend the language without having
to add features to the language itself.
As a practical example I would like to take a first item from a list
my_list = []
first = my_list[0
15 matches
Mail list logo