4 ms·
Also, instantiating the dict on each call to the `parse` staticmethod is not very efficient. Why not create the dict as a static/class variable and place the me
by avyfain 10y ago
Also, instantiating the dict on each call to the `parse` staticmethod is not very efficient. Why not create the dict as a static/class variable and place the method in a classmethod instead?
- mikeckennedy 10y agoYes, I think I mention that in the lesson. You have a trade off. 1. Instantiate the dict each time, make the code super readable and the choices right next to where they are used. 2. Make the code efficient, move the dict to a static / instance level variable away from the use case at the cost of clarity and maintainability. My slide chose clarity and I would recommend you write clear code over fast code until you profile it and see it's too slow. That was my motivation for the slide and demo.