Skip to content

Conversation

@Li-Xiang-Ideal
Copy link
Contributor

Now Range is still not applicable to general di like Pi. I'm not sure if it's worth sacrificing efficiency to make Range work for general real-valued di as IterationFunction does.

@rocky
Copy link
Member

rocky commented Dec 17, 2023

LGTM

@rocky rocky merged commit 4d52275 into master Dec 17, 2023
@rocky rocky deleted the fix-range branch December 17, 2023 13:53
@rocky
Copy link
Member

rocky commented Dec 17, 2023

I'm not sure if it's worth sacrificing efficiency to make Range work for general real-valued di as IterationFunction does.

The way to get efficiency here is to note that with respect to the implementation "di" does not change. So at the expense of some complexity, a determination at the top of the code can be made to decide what category "di" is and choose the implementation that has been customized for that.

This though can be done in future PR's if/when desired.

There was a similar idea used in other pr where some code that does not change inside a loop was moved outside of the loop.

In programming languages that do not allow dynamically changing variable types, like C, C++, Java, Go, or Rust there are "optimizing" compilers that do this kind of thing automatically. In Python, technology for stuff like this does not exist (yet), so these kinds of things are done by changing the program in roughy the same kind of way that the optimizing compiler detects and does. It is possible Python may advance to the stage where this kind of stuff is done automatically.

So that's why, personally, I am more interested in algorithmic and overall structural changes rather than the kinds of changes that are typically done by "optimizing" compilers. That said, if this is how others want to spend their time and focus on, sure, go for it as long at it does not complicate the code inordinately.

@Li-Xiang-Ideal Li-Xiang-Ideal restored the fix-range branch December 18, 2023 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants