Python Forum
For looping over a list, editing the list from inside the loop?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For looping over a list, editing the list from inside the loop?
#3
I understand and recall that from courses I had long ago. However in that case I can't know in advance how much nodes there will be, nor how they will be connected...etc... More than this, I don't need to know, I'm supposed to let the program make it himself if I were to follow the concept of random forests.
It feels extremely inefficient to remake a loop over each forest then each tree then each depth then each row everytime I create a new node.
Also, the WM object, containing all the information of the nodes, will be a very big object, and will be the one which will limit my ram usage (in a future inplementation, after making a single forest to work, I'm planning to have n+6 forests, n being dependent on the size of the data to analyze, each forest containing tress of 2^depth nodes).

For all these reasons, I felt compelled to store the data in an object and never make duplicates of it, and working directly in that object to create all the parameters, and using the same object to make predictions afterwards (I know I'm not forced to do that now, but plan to later expand on the code I'm making now)
I am aware there is likely another way to do what I'm trying to do, and that's the reason I'm asking here: to get some pointers so that I can find these alternatives :) Also, I'm not explaining all this to say that I'm right, it's just to explain more of the context and why I'm doing it in this weird way.

Anyways, thanks for having taken the time to answer.

Krookroo
Reply


Messages In This Thread
RE: For looping over a list, editing the list from inside the loop? - by Krookroo - Aug-28-2017, 01:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 452 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,776 Nov-07-2023, 09:49 AM
Last Post: buran
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,190 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  for loops break when I call the list I'm looping through Radical 4 913 Sep-18-2023, 07:52 AM
Last Post: buran
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 802 May-02-2023, 08:40 AM
Last Post: Gribouillis
  Delete strings from a list to create a new only number list Dvdscot 8 1,559 May-01-2023, 09:06 PM
Last Post: deanhystad
  List all possibilities of a nested-list by flattened lists sparkt 1 930 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Сheck if an element from a list is in another list that contains a namedtuple elnk 8 1,862 Oct-26-2022, 04:03 PM
Last Post: deanhystad
  Help adding a loop inside a loop Extra 31 4,627 Oct-23-2022, 12:16 AM
Last Post: Extra
  convert this List Comprehensions to loop jacklee26 8 1,536 Oct-21-2022, 04:25 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020