Here's about 9 million lines that would stop working: https://github.com/search?l=Python&q=except+IndexError&type=Code
On Thu, Nov 26, 2020 at 10:20 AM Mathew M. Noel via Python-ideas < python-ideas@python.org> wrote: > Circular indexing will only extend the range of allowable indices to the > set of > > all integers !!! > > > Can you provide some example of the "billions of lines of working code" > that the circular indexing scheme supposedly breaks so that we can have a > more informed discussion? > > Deeper mathematical reason behind circular indexing is that it makes the > use of negative indices logically consistent and simplifies implementation > of the widely used convolution operation in signal processing. > > > ------------------------------ > *From:* David Mertz <me...@gnosis.cx> > *Sent:* Thursday, November 26, 2020 1:15 AM > *To:* Mathew M. Noel > *Cc:* python-ideas; m...@pradyunsg.me > *Subject:* Re: [Python-ideas] Getting rid of FOR loops and simplifying > cicular conviolutions with Circular Indexing > > You've started three separate threads to propose something that has > exactly zero chance of happening, and would be of limited use in uncommon > cases. And that would break literally billions of lines of working code. > > If you want the modulo operator, you are more than welcome to use it. If > you want to subclass list, have at it. > > On Wed, Nov 25, 2020, 12:48 PM Mathew M. Noel via Python-ideas < > python-ideas@python.org> wrote: > >> If circular indexing is used then instead of using a double FOR loop to >> go through a list M times we can iterate from 0 to M*N (where N is the >> length of the list) !!! >> >> >> Almost all Machine Learning (ML) algorithms iterate for some predefined >> epochs over a large data-set. So a double FOR loop is extremely common in >> ML. Using circular indexing gets rid of this extra FOR loop. If we have to >> iterate 2 times you can iterate using range(-n,n) but in most cases you >> need to iterate over 10 or more epochs in ML. >> >> >> Most scientific applications of Python involve an outer FOR loop which >> progressively refines an approximation with an inner FOR loop by going >> through a list of items. So circular indexing is useful. In the following I >> discuss increasingly compelling reasons for adopting a circular indexing >> scheme in Python. >> >> >> Python uses an index of -1 to index the last element in a list. Since -1 >> occurs before 0 we might think of the elements of the linear list are being >> bent into a circle making the last element occur before the 0th element. >> Consider a list with n elements: it would be perfectly reasonable to >> address the element 0 of the list using an index of n since n occurs after >> n-1 (if we assume that the list is bent into a circle). This feature can >> prove to be extremely useful. Consider the following example: >> >> >> days_of_the_week = >> ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] >> >> It would be nice if >> >> days_of_the_week[0] >> >> is the same as >> >> days_of_the_week[7] >> >> is the same as >> >> days_of_the_week[14] etc >> >> In other words use modular indexing. In other words if the index is outside >> the range 0 to n-1, we simply take the remainder when the index is divided >> by n as the index. >> Because of the close relationship between finite length sequences and >> periodic sequences this feature might simplify scientific computing(circular >> convolution etc). >> >> If circular indexing is used then we don't need the arbitrary rule that >> -1 is the index of the last element. Since -1 is the same as n-1 >> automatically in modular arithmetic. >> >> >> A trivial objection: "why not use list_name[i%n] whenever we need this >> feature?" By the same token we could do away with negative indices and use >> -1%n for example when we need to index with -1! >> >> Its unclear why that people have an irrational preference for indices >> that lie to the left of 0 while strongly rejecting the idea of indices that >> lie to the right of n-1! >> >> Python does not raise a "index out of bound" exception for negative >> indices like other programming languages. If this negative indexing is a >> "feature" (although it allows some fatal errors to slip) then indices above >> n-1 can also be considered a feature! >> >> Are there any deep mathematical reasons for adopting circular >> convention? >> Circular convolution is a most important operation in a wide variety of >> scientific disciplines since the Discrete Fourier Transform (DFT) of the >> circular convolution of two signals is the product of the transforms. >> Because of the universal applicability of Fourier ideas in science and the >> close mathematical relationship between finite length and periodic >> sequences circular indexing is extensively used in signal processing and >> mathematics. >> >> We can extend the idea of circular indexing to multidimensional arrays. A >> 2D array can be folded into a cylinder for indexing. Further this cylinder >> can be folded into a toroid to reduce a triple FOR loop to a single FOR >> loop. A deep mathematical justification for cylindrical indexing of 2D and >> in general nD arrays is offered by the fact that n-dimensional DFT reduces >> n-dimensional circular convolution to element-wise multiplication. >> >> _______________________________________________ >> 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/5TJYKFLBHB26WEFFQXMY6AGWS34XTIUR/ >> 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/3KTOJDTE6MDGD3Z2DACV4NGW2YXPNFKZ/ > 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/7KCOFKWS2RRQEOWZASXZX47I3JVENZU3/ Code of Conduct: http://python.org/psf/codeofconduct/