[Python-ideas] Circular Indexing

2020-11-24 Thread Mathew M. Noel via Python-ideas
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 addre

[Python-ideas] Circular Indexing and FOR loop minimization

2020-11-24 Thread Mathew M. Noel via Python-ideas
As discussed earlier on the post on 'Circular Indexing', considering interpreting indices that lie outside the range 0 to n-1 modulo n for list indexing. Thus element n corresponds to element 0, n+1 to element 1 and so on. This has two consequences: 1.) Makes the Python convention of interpret

[Python-ideas] Getting rid of FOR loops and simplifying cicular conviolutions with Circular Indexing

2020-11-25 Thread Mathew M. Noel via Python-ideas
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 e

[Python-ideas] Re: Getting rid of FOR loops and simplifying cicular conviolutions with Circular Indexing

2020-11-25 Thread Mathew M. Noel via Python-ideas
: python-ideas@python.org; m...@pradyunsg.me Subject: Re: [Python-ideas] Getting rid of FOR loops and simplifying cicular conviolutions with Circular Indexing days_of_the_week[14 % 7] There ya go! On Wed, Nov 25, 2020 at 12:51 PM Mathew M. Noel via Python-ideas mailto:python-ideas@python.org

[Python-ideas] Re: Getting rid of FOR loops and simplifying cicular convolutions with Circular Indexing

2020-11-26 Thread Mathew M. Noel via Python-ideas
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 mailto:python-ideas@python.o