Electron microscopy
 
Circular Dependencies in Python Execution
- Python for Integrated Circuits -
- An Online Book -
Python for Integrated Circuits                                                                                   http://www.globalsino.com/ICs/        


Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix

=================================================================================

============================================

Some cases are easier to cause circular dependencies in Python execution:
          i) Putting imports within a function will cause calls to that function to take longer. However, putting the import statement inside of a function can prevent circular dependencies. For instance, if there are two modules, x.py and y.py, and they both need to import each other, which causes a circular dependency when you import one of the modules causing an infinite loop. If the import statement is moved into one of the modules then it won't try to import the other module till the function is called, and that module will already be imported, so no infinite loop.
          ii) Object oriented programming often leads me to circular dependencies.

Some tricks can be used to avoid circular dependencies:
          i) Move one of the from imports at the bottom of the module.
          ii) Move one of the from imports inside the function or method that is actually requiring the import.
          iii) Change one of the two from imports to be an import that looks like: import xyz.

         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         
         

 

 

 

 

 

 

 

 

 

 

=================================================================================