[Python-ideas] Re: basic matrix object

2020-08-13 Thread Marco Sulla
On Fri, 14 Aug 2020 at 03:16, Steven D'Aprano  wrote:
> Funny you mention this, I have been working on a Matrix object for
> precisely the use-case you discuss (secondary school maths), where
> performance is not critical and the dimensions of the matrix is
> typically single digits.

This is really good. I think that numpy is a practical project, but I
feel it hard to understand for people that come from Python and not
from Matlab.
Maybe the API for such a module can be released initially as a
provisional API, as at the pathlib and asyncio beginnings?
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/3AVVWCTRD675SM3HF755RMLQLO5INXTX/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: basic matrix object

2020-08-13 Thread Guido van Rossum
That's food for thought. I have to admit that I have forgotten almost
everything about linear algebra that I was ever taught -- and I was never
taught numerical accuracy concerns in this context, since we were allowed
to use only pencil and paper (in high school as well as college), so the
problems were always constructed to ensure that correct answers contained
nothing more complicated than 0, 0.5, 1 or sqrt(2). At this point I have a
hard time reproducing multiplication for two 2x2 matrices (the only thing I
remember is that it was the first example of something where AxB != BxA).

What gives me hope though is that Steven has been thinking about this
somewhat seriously already, and given that he successfully chose what to
include or exclude for the statistics module, I trust him to know how much
to put into a Matrix class as well. Certainly I trust him to come up with a
reasonable strawman whose tires we can all kick.

My own strawman would be to limit a Matrix to 2-dimensionality -- I believe
that even my college linear algebra introduction (for math majors!) didn't
touch upon higher dimensionality, and I doubt that what I learned in high
school about the topic went beyond 3x3 (it might not even have treated
non-square matrices).

In terms of numerical care (that topic to which I never warmed up), which
operations from the OP's list need more than statistics._sum() when limited
to NxM matrices for single-digit N and M? (He named "matrix multiplication,
transposition, addition, linear problem solving, determinant.")

On Thu, Aug 13, 2020 at 9:04 PM Stephen J. Turnbull <
turnbull.stephen...@u.tsukuba.ac.jp> wrote:

> Guido van Rossum writes:
>
>  > I was going to say that such a matrix module would be better of in
>  > PyPI, but then I recalled how the statistics module got created,
>  > and I think that the same reasoning from PEP 450 applies here too
>  > (https://www.python.org/dev/peps/pep-0450/#rationale).
>  >
>  > So I'd say go for it!
>
> I disagree that that rationale applies.  Let's consider where the
> statistics module stopped, and why I think that's the right place to
> stop.  Simple statistics on *single* variables, as proposed by PEP
> 450, are useful in many contexts to summarize data sets.  You see them
> frequently in newpaper and Wikipedia articles, serious blog posts, and
> even on Twitter.
>
> PEP 450 mentions, but does not propose to provide, linear regression
> (presumably ordinary least squares -- as with median and mode, there
> are many ways to compute a regression line).  The PEP mentions
> covariance and correlation coefficients once each, and remarks that
> the API design is unclear.  I think that omission was the better part
> of valor.  Even on Twitter, it's hard to abuse the combination of mean
> and standard deviation (without outright lies about the values, of
> course).  But most uses of correlation and regression are more or less
> abusive.  That's true even in more serious venues (Murray &
> Herrnstein's "The Bell Curve" comes immediately to mind).  Almost all
> uses of multiple regression outside of highly technical academic
> publications are abusive.
>
> I don't mean to say "keep power tools out of the reach of the
> #ToddlerInChief and his minions".[1]  Rather, I mean to say that most
> serious languages and packages for these applications (such as R, and
> closer to home numpy and pandas) provide substantial documentation
> suggesting *appropriate* use and pointing to the texts on algorithms
> and caveats.  Steven doesn't do that with statistics -- and correctly
> so, he doesn't need to.  None of the calculations he implements are in
> any way controversial as calculations.  To the extent that different
> users might want slightly different definitions of mode or median, the
> ones provided are good enough for stdlib purposes.  Nor are the
> interpretations of the results of the various calculations at all
> controversial.[2]
>
> But even a two-dimensional regression y on x is fraught.  Should we
> include the Anscombe[3] data and require a plotting function so users
> can see what they're getting into?  I think Steven would say that's
> *way* beyond the scope of his package -- and I agree.  Let's not go
> there.  At all.  Let users who need that stuff use packages that
> encourage them and help them do it right.
>
> I don't find the "teaching high school linear/matrix algebra" use case
> persuasive.  I taught "MBA Statistics for Liberal Arts Majors" for a
> decade.  Writing simple matrix classes was an assignment, and then
> they used their own classes to implement covariance, correlation, and
> OLS.  I don't think having a "canned" matrix class would have been of
> benefit to them -- a substantial fraction (10% < x < 50%) did get some
> idea of what was going on "inside" those calculations by programming
> them themselves plus a bit of printf debugging, which neither the
> linear algebra equations nor the sum operator I wrote on the
> whiteboard did.  I will say

[Python-ideas] Re: basic matrix object

2020-08-13 Thread Stephen J. Turnbull
Guido van Rossum writes:

 > I was going to say that such a matrix module would be better of in
 > PyPI, but then I recalled how the statistics module got created,
 > and I think that the same reasoning from PEP 450 applies here too
 > (https://www.python.org/dev/peps/pep-0450/#rationale).
 >
 > So I'd say go for it!

I disagree that that rationale applies.  Let's consider where the
statistics module stopped, and why I think that's the right place to
stop.  Simple statistics on *single* variables, as proposed by PEP
450, are useful in many contexts to summarize data sets.  You see them
frequently in newpaper and Wikipedia articles, serious blog posts, and
even on Twitter.

PEP 450 mentions, but does not propose to provide, linear regression
(presumably ordinary least squares -- as with median and mode, there
are many ways to compute a regression line).  The PEP mentions
covariance and correlation coefficients once each, and remarks that
the API design is unclear.  I think that omission was the better part
of valor.  Even on Twitter, it's hard to abuse the combination of mean
and standard deviation (without outright lies about the values, of
course).  But most uses of correlation and regression are more or less
abusive.  That's true even in more serious venues (Murray &
Herrnstein's "The Bell Curve" comes immediately to mind).  Almost all
uses of multiple regression outside of highly technical academic
publications are abusive.

I don't mean to say "keep power tools out of the reach of the
#ToddlerInChief and his minions".[1]  Rather, I mean to say that most
serious languages and packages for these applications (such as R, and
closer to home numpy and pandas) provide substantial documentation
suggesting *appropriate* use and pointing to the texts on algorithms
and caveats.  Steven doesn't do that with statistics -- and correctly
so, he doesn't need to.  None of the calculations he implements are in
any way controversial as calculations.  To the extent that different
users might want slightly different definitions of mode or median, the
ones provided are good enough for stdlib purposes.  Nor are the
interpretations of the results of the various calculations at all
controversial.[2]

But even a two-dimensional regression y on x is fraught.  Should we
include the Anscombe[3] data and require a plotting function so users
can see what they're getting into?  I think Steven would say that's
*way* beyond the scope of his package -- and I agree.  Let's not go
there.  At all.  Let users who need that stuff use packages that
encourage them and help them do it right.

I don't find the "teaching high school linear/matrix algebra" use case
persuasive.  I taught "MBA Statistics for Liberal Arts Majors" for a
decade.  Writing simple matrix classes was an assignment, and then
they used their own classes to implement covariance, correlation, and
OLS.  I don't think having a "canned" matrix class would have been of
benefit to them -- a substantial fraction (10% < x < 50%) did get some
idea of what was going on "inside" those calculations by programming
them themselves plus a bit of printf debugging, which neither the
linear algebra equations nor the sum operator I wrote on the
whiteboard did.  I will say I wish I had Steven's implementation of
sum() at hand back then to show them to give them some idea of the
care that numerical accuracy demands.

I cannot speak to engineering uses of matrix computations.  If someone
produces use cases that fit into the list of operations proposed
(addition, negation, multiplication, inverse, transposition, scalar
multiplication, solving linear equation systems, and determinants, I
will concede it's useful and fall back to +/- 0.

However, I think the comparison to multivariate statistics is
enlightening.  You see many two-dimensional tables in public
discussions (even on Twitter!)  but they are not treated as matrices.
Now, it's true that *every* basic matrix calculation (except
multiplication by a scalar) requires the same kind of care that
statistics.sum exerts, but having provided that, what have you
bought?  Not a lot, as far as I can see -- applications of matrix
algebra are extremely diverse, and many require just as much attention
to detail as the basic operations do.

In sum, I suspect that simply providing numerically stable algorithms
for those computations isn't enough for useful engineering work -- as
with multivariate statistics, you're not even halfway to useful and
accurate computations, and the diversity is explosive.  How to choose?


Footnotes: 
[1]  Any fans of cubic regression models for epidemiology?  No?  OK, then.

[2]  They can be abused.  I did so myself just this morning, to tease
a statistically literate friend.  But it takes a bit of effort.

[3]  https://stat.ethz.ch/R-manual/R-patched/library/datasets/html/anscombe.html
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-idea

[Python-ideas] Re: basic matrix object

2020-08-13 Thread Guido van Rossum
I was going to say that such a matrix module would be better of in PyPI,
but then I recalled how the statistics module got created, and I think that
the same reasoning from PEP 450 applies here too (
https://www.python.org/dev/peps/pep-0450/#rationale). So I'd say go for it!
I think it would even be okay to deviate from the numpy.matrix API (though
not needlessly).

On Thu, Aug 13, 2020 at 6:20 PM Steven D'Aprano  wrote:

> On Thu, Aug 13, 2020 at 11:17:00PM +0100, Stefano Borini wrote:
>
> > The math module has plenty of mathematical functions that are very
> > interesting, but no Matrix object.
>
> Funny you mention this, I have been working on a Matrix object for
> precisely the use-case you discuss (secondary school maths), where
> performance is not critical and the dimensions of the matrix is
> typically single digits.
>
> I, um, got distracted with some over-engineering and then distracted
> further by work and life, but perhaps this is a good opportunity for me
> to get it back on track.
>
>
> > Generally, when a Matrix object is needed, numpy is the point of
> > reference, but numpy requires understanding pip, installing modules,
> > maybe creating a virtual environment and finally understanding numpy.
>
> And numpy also offers a surprising interface that doesn't match
> matrices. (Well, surprising to those who aren't heavy users of numpy :-)
>
> py> A = numpy.array([[1, 2], [3, 4]])
> py> A*A
> array([[ 1,  4],
>[ 9, 16]])
>
> To get *matrix multiplication* you have to use the `@` multiplication
> operator from PEP 465:
>
> py> A@A
> array([[ 7, 10],
>[15, 22]])
>
> https://www.python.org/dev/peps/pep-0465/
>
> But what's really surprising about numpy arrays is broadcasting:
>
> py> A = numpy.array([[1, 2], [3, 4]])
> py> B = numpy.array([[10, 20]])
> py> A + B
> array([[11, 22],
>[13, 24]])
>
> I don't know if broadcasting is actually useful or not, but
> it's not what you want when doing matrix arithmetic at a
> secondary school level.
>
>
> --
> Steven
> ___
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/FARJRNHNLNGRVJA3ITSUSAJCXOUUYKA2/
> Code of Conduct: http://python.org/psf/codeofconduct/
>


-- 
--Guido van Rossum (python.org/~guido)
*Pronouns: he/him **(why is my pronoun here?)*

___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/WJQHAPZBWLTSSLMB4KYX2UZEGBNUM6GO/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: basic matrix object

2020-08-13 Thread Matthias Bussonnier
numpy arrays are ... arrays, if you want * to do matmul, use
numpy.matrix (which is soft deprecated since now we have @), and will
do what you expect with square matrix times vector.

broadcasting is the natural extension of array `op` scalar on... arrays.

Say you have an array Pressure with 3 coord  : longitude , latitude ,
time, and a typical  Mean value M with coord: latitude , longitude
Then you can "just" do `Pressure - M`,
if actually your Mean is just function of time then you can same, do P
- M and it broadcast on the other axes. So yes, extremely useful.
If you use things like xarray then it will not  match dimension base
on their neame, and not on their size, so it's less "magical" and more
accurate when some dimensions have the same size.

But of course that's for arrays, not matrices.
-- 
M

On Thu, 13 Aug 2020 at 18:17, Steven D'Aprano  wrote:
>
> On Thu, Aug 13, 2020 at 11:17:00PM +0100, Stefano Borini wrote:
>
> > The math module has plenty of mathematical functions that are very
> > interesting, but no Matrix object.
>
> Funny you mention this, I have been working on a Matrix object for
> precisely the use-case you discuss (secondary school maths), where
> performance is not critical and the dimensions of the matrix is
> typically single digits.
>
> I, um, got distracted with some over-engineering and then distracted
> further by work and life, but perhaps this is a good opportunity for me
> to get it back on track.
>
>
> > Generally, when a Matrix object is needed, numpy is the point of
> > reference, but numpy requires understanding pip, installing modules,
> > maybe creating a virtual environment and finally understanding numpy.
>
> And numpy also offers a surprising interface that doesn't match
> matrices. (Well, surprising to those who aren't heavy users of numpy :-)
>
> py> A = numpy.array([[1, 2], [3, 4]])
> py> A*A
> array([[ 1,  4],
>[ 9, 16]])
>
> To get *matrix multiplication* you have to use the `@` multiplication
> operator from PEP 465:
>
> py> A@A
> array([[ 7, 10],
>[15, 22]])
>
> https://www.python.org/dev/peps/pep-0465/
>
> But what's really surprising about numpy arrays is broadcasting:
>
> py> A = numpy.array([[1, 2], [3, 4]])
> py> B = numpy.array([[10, 20]])
> py> A + B
> array([[11, 22],
>[13, 24]])
>
> I don't know if broadcasting is actually useful or not, but
> it's not what you want when doing matrix arithmetic at a
> secondary school level.
>
>
> --
> Steven
> ___
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/FARJRNHNLNGRVJA3ITSUSAJCXOUUYKA2/
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FFGBFUESWMOYWVVW2T6ZHV6DCLE5MQLG/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: basic matrix object

2020-08-13 Thread Steven D'Aprano
On Thu, Aug 13, 2020 at 11:17:00PM +0100, Stefano Borini wrote:

> The math module has plenty of mathematical functions that are very
> interesting, but no Matrix object.

Funny you mention this, I have been working on a Matrix object for 
precisely the use-case you discuss (secondary school maths), where 
performance is not critical and the dimensions of the matrix is 
typically single digits.

I, um, got distracted with some over-engineering and then distracted 
further by work and life, but perhaps this is a good opportunity for me 
to get it back on track.


> Generally, when a Matrix object is needed, numpy is the point of
> reference, but numpy requires understanding pip, installing modules,
> maybe creating a virtual environment and finally understanding numpy.

And numpy also offers a surprising interface that doesn't match 
matrices. (Well, surprising to those who aren't heavy users of numpy :-)

py> A = numpy.array([[1, 2], [3, 4]])
py> A*A
array([[ 1,  4],
   [ 9, 16]])

To get *matrix multiplication* you have to use the `@` multiplication 
operator from PEP 465:

py> A@A
array([[ 7, 10],
   [15, 22]])

https://www.python.org/dev/peps/pep-0465/

But what's really surprising about numpy arrays is broadcasting:

py> A = numpy.array([[1, 2], [3, 4]])
py> B = numpy.array([[10, 20]])
py> A + B
array([[11, 22],
   [13, 24]])

I don't know if broadcasting is actually useful or not, but 
it's not what you want when doing matrix arithmetic at a 
secondary school level.


-- 
Steven
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/FARJRNHNLNGRVJA3ITSUSAJCXOUUYKA2/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make start, stop, step properties on islice

2020-08-13 Thread Steven D'Aprano
On Thu, Aug 13, 2020 at 12:38:38PM -0700, Christopher Barker wrote:
> On Thu, Aug 13, 2020 at 12:27 PM Ben Rudiak-Gould 
> wrote:
> 
> >
> > I think islice should implement __length_hint__, though. As of 3.8.5 it
> > doesn't.
> >
> 
> And it could support __len__, and raise an Exception when the underlying
> iterable doesn’t support it.

"Iterators should support len" is one of those features that everyone 
thinks they want, but nobody can show how it is actually workable as a 
language or library feature in the most general case.

It might, sometimes, be workable for a specific custom iterator that you 
control yourself, in an application. But as a library feature, it is 
unusable. The problem is that the concept of "the length of an iterator" 
is unworkable in general, leading to confusing and contradictory 
behaviour.

This seem reasonable at first:


orig = 'abcd'
it = iter(orig)
assert len(it) == 4


but as soon as you begin to iterate over the iterator, we run into 
trouble. Should `len(it)` return the length of the original sequence, or 
track the number of currently remaining elements? Both cases are 
troublesome.

(1) We return the length of the original sequence. Then we have the 
surprising result that `len(it) != len(list(it))`.


item = next(it)
assert item == 'a'
assert len(it) == len(orig)
list(it)  # ['b', 'c', 'd'] has length 3, not 4


This violates the critical invariant that if an iterable has length N, 
then iterating over it (with no early exit) will take N loops.


count = 0
n = len(it)
for x in it:
count += 1
assert count == n


If the assertion fails, then your len function lied to you, and we will 
have a lot of bug reports that len is inaccurate.


(2) We track the remaining items in the iterator. Then we violate the 
critical invariant that the length of a sequence (or sequence-like 
object) should not depend on whether you have iterated over it or not.


it = iter(orig)
assert len(it) == 4
for x in it:
pass
assert len(it) == 0


Why is this a critical invariant? Because otherwise we introduce a 
surprising temporal coupling in your code, making algorithms fragile and 
likely buggy. The length of the iterator depends on whether we check it 
before or after the loop, which is bad:


def average(iterable):
return sum(iterable)/len(iterable)

def average(iterable):
n = len(iterable)
return sum(iterable)/n

 
If those two functions don't give the same result, then your length 
calculation is broken.

Whichever strategy we pick for the length of an iterator, we're going to 
surprise people and lead to fragile, buggy code.

The easy cases:


it = iter(sequence)
n = len(it)
for item in it:
process(item)
print(f"Processed {n} items")


where we work with a fresh iterator, retrieve the length *before* 
iterating, and then *only* iterate fully to completion, might work okay, 
but as soon as you get to more complex cases the idea of len for 
iterators is a minefield.

The only generally correct solution is to not pick either strategy (1) 
or strategy (2), both of which are sometimes what the caller expects 
but sometimes leads to surprising results and fragile, broken code, but 
instead refuse to guess.


-- 
Steven
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/S2TMXOL5KDW5IDNQ2MAAMAYGTF5S3FOC/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: basic matrix object

2020-08-13 Thread David Mertz
This is a lot to add to Python itself to poorly reproduce well-tested
functionally in a very popular library. There are many Python distributions
that come with that extra battery included, just not the one from the PSF.

On Thu, Aug 13, 2020, 6:20 PM Stefano Borini 
wrote:

> Excuse me if I am out of the loop and this is already available, but I
> haven't seen it and googling is not exactly easy as numpy introduces
> considerable noise.
>
> With the introduction of the statistics module, the standard library
> provides basic statistical functions that can be useful in many
> scenarios, including teaching.
> The math module has plenty of mathematical functions that are very
> interesting, but no Matrix object. When newcomers want to have a
> matrix object, they end up
> implementing a list of lists (as suggested by the documentation, e.g.
> see
> https://docs.python.org/3/tutorial/datastructures.html?highlight=matrix#nested-list-comprehensions
> and
> https://docs.python.org/3/faq/programming.html?highlight=matrix#how-do-i-create-a-multidimensional-list
> )
> but it's ambiguous
> (is each entry a row or a column?), and does not enforce types or
> equal length of each entry.
>
> Generally, when a Matrix object is needed, numpy is the point of
> reference, but numpy requires understanding pip, installing modules,
> maybe creating a virtual environment and finally understanding numpy.
>
> I would propose a simple, straightforward, low performance object to
> perform trivial operations such as matrix multiplication,
> transposition, addition, linear problem solving, determinant. The
> absolute bare minimum for an introductory linear algebra course.
> The syntax should mimic numpy to train newcomers to the numpy syntax
> whenever possible, and of course should implement the @ operator.
>
> There is already a similar entity in the "array" module, which is a
> simple version of a numpy array, except that is only one-dimensional.
>
> --
> Kind regards,
>
> Stefano Borini
> ___
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/R334EPWCXRM3RXFEUXVN4HYG6WQKKCGT/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/ULD7T4PS7WLN3NIYGVP5ZT53XAIVK4HS/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] basic matrix object

2020-08-13 Thread Stefano Borini
Excuse me if I am out of the loop and this is already available, but I
haven't seen it and googling is not exactly easy as numpy introduces
considerable noise.

With the introduction of the statistics module, the standard library
provides basic statistical functions that can be useful in many
scenarios, including teaching.
The math module has plenty of mathematical functions that are very
interesting, but no Matrix object. When newcomers want to have a
matrix object, they end up
implementing a list of lists (as suggested by the documentation, e.g.
see 
https://docs.python.org/3/tutorial/datastructures.html?highlight=matrix#nested-list-comprehensions
and 
https://docs.python.org/3/faq/programming.html?highlight=matrix#how-do-i-create-a-multidimensional-list)
but it's ambiguous
(is each entry a row or a column?), and does not enforce types or
equal length of each entry.

Generally, when a Matrix object is needed, numpy is the point of
reference, but numpy requires understanding pip, installing modules,
maybe creating a virtual environment and finally understanding numpy.

I would propose a simple, straightforward, low performance object to
perform trivial operations such as matrix multiplication,
transposition, addition, linear problem solving, determinant. The
absolute bare minimum for an introductory linear algebra course.
The syntax should mimic numpy to train newcomers to the numpy syntax
whenever possible, and of course should implement the @ operator.

There is already a similar entity in the "array" module, which is a
simple version of a numpy array, except that is only one-dimensional.

-- 
Kind regards,

Stefano Borini
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/R334EPWCXRM3RXFEUXVN4HYG6WQKKCGT/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Aside RE: Re: macaddress or networkaddress module

2020-08-13 Thread Paul Moore
On Thu, 13 Aug 2020 at 22:22, Stefano Borini  wrote:
>
> On Mon, 6 Apr 2020 at 09:40, Steve Barnes  wrote:
> >
> > As an aside I have a perfect example to back up what Paul is saying below. 
> > I work for a large corporation where developers are permitted to install 
> > python modules on their development machines, (subject to some licence 
> > restrictions), but the proxy settings required to get to PyPi vary from 
> > user to user, site to site, day to day (sometimes hour to hour) and 
> > connection type to connection type, e.g. If you are connected via WiFi you 
> > need to use a different proxy to that needed if you are on a wired 
> > connection and on a VPN (we have more than one in use) different again.
>
> FYI there's an issue open on pip to allow for multiple proxies. I have
> this exact situation as well.
>
> https://github.com/pypa/pip/issues/8232

Even though this conversation references the situation I described
initially, I'm against adding more complexity to how tools like pip
deal with the network. That simply isn't scalable - every tool ends up
having to implement the same set of options, configuration, etc.

My point was challenging the statement that "if the stdlib were
designed from scratch today rather than over the past 30 years, I
think it would have less than it does, not more". It may be true, but
IMO it would be a mistake, and would have definitely damaged Python's
popularity - the "batteries included" philosophy is a *huge* selling
point in many environments, that aren't immediately obvious to people
who have the luxury of easy and permanent access to the internet.

I'm not against pushing people to publish libraries on PyPI (I've done
that myself many times) but that doesn't mean I support omitting
important functionality from the stdlib "because you can get it from
PyPI". The tricky bit is deciding what's important :-)

(Off topic, but IMO the scalable solution to the whole proxy/network
access issue, is to have core Python integrate directly with platform
networking, so that if your browser can see a webpage, then so can
Python. Then tools don't need *any* proxy configuration, you just set
up your system and you're done. Unfortunately, that's a really hard
problem due to Python's reliance on openssl, which doesn't integrate
and has an API that isn't easily emulatable with platform libraries -
at least, as I understand it from the people who are looking at these
sorts of things, I'm a long way from an expert in networking).

Paul
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/DFFDFHDNGV7O6BPBWXEJI63H3SCERNZZ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Aside RE: Re: macaddress or networkaddress module

2020-08-13 Thread Stefano Borini
On Mon, 6 Apr 2020 at 09:40, Steve Barnes  wrote:
>
> As an aside I have a perfect example to back up what Paul is saying below. I 
> work for a large corporation where developers are permitted to install python 
> modules on their development machines, (subject to some licence 
> restrictions), but the proxy settings required to get to PyPi vary from user 
> to user, site to site, day to day (sometimes hour to hour) and connection 
> type to connection type, e.g. If you are connected via WiFi you need to use a 
> different proxy to that needed if you are on a wired connection and on a VPN 
> (we have more than one in use) different again.

FYI there's an issue open on pip to allow for multiple proxies. I have
this exact situation as well.

https://github.com/pypa/pip/issues/8232


-- 
Kind regards,

Stefano Borini
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/X7OFRRGBWGSAPC6VW55SG3NBIBZL33UU/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make start, stop, step properties on islice

2020-08-13 Thread Christopher Barker
On Thu, Aug 13, 2020 at 12:27 PM Ben Rudiak-Gould 
wrote:

>
> I think islice should implement __length_hint__, though. As of 3.8.5 it
> doesn't.
>

And it could support __len__, and raise an Exception when the underlying
iterable doesn’t support it.

I know that itertools needs to support arbitrary iterable, but I do wish it
provided more Sequence features when it could.

islice, for instance, could support negative indexes when it is wrapping a
Sequence.

-CHB
-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/NJV4ADNLHLFU5BMNPXCPB4XP6MCOHTTM/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make start, stop, step properties on islice

2020-08-13 Thread Ben Rudiak-Gould
On Wed, Aug 12, 2020 at 8:49 AM David Mertz  wrote:

> The start/stop/step sound like they might be nice. But that wouldn't give
> you a length, since you never know when an iterator will be exhausted.  I
> feel like `len(islice(it, 1, 1_000_000))` telling you the "maximum possible
> length" is more a danger than a help.
>

I think islice should implement __length_hint__, though. As of 3.8.5 it
doesn't.
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KSGNEU7FMZ7LV6Z6HI7TRWBBDEUC6VXX/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Re: Make start, stop, step properties on islice

2020-08-13 Thread Mathew Elman
You're absolutely right, I realized that __len__ would be the maximum possible 
length after posting, and it would likely be more dangerous than helpful
___
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/RHTEFUOMWIGPVHXN46YPTL2RDHHB6RPQ/
Code of Conduct: http://python.org/psf/codeofconduct/