Login Register






unused imports filter_list
Author
Message
unused imports #1
So i'm making a random encounter generator for a game i am making (isn't a good game just so i can learn python). But anyway i have a lot of unused imports for some reason does this effect performance at all?

here is the code if it helps
Code:
import random number = random.randint(1,10) if number == 1: from encounters import _1 elif number == 2: from encounters import _2 elif number == 3: from encounters import _3 elif number == 4: from encounters import _4 elif number == 5: from encounters import _5 elif number == 6: from encounters import _6 elif number == 7: from encounters import _7 elif number == 8: from encounters import _8 elif number == 9: from encounters import _9 elif number == 10: from encounters import _10
All of the imports from encounters are showing as unused, i'm not sure if this is just because they are in an if statement.
there are 10 types of people in this world,
those who understand binary and those who don't.

skype name: J4W3S.23

Reply

unused imports #2
So i'm making a random encounter generator for a game i am making (isn't a good game just so i can learn python). But anyway i have a lot of unused imports for some reason does this effect performance at all?

here is the code if it helps
Code:
import random number = random.randint(1,10) if number == 1: from encounters import _1 elif number == 2: from encounters import _2 elif number == 3: from encounters import _3 elif number == 4: from encounters import _4 elif number == 5: from encounters import _5 elif number == 6: from encounters import _6 elif number == 7: from encounters import _7 elif number == 8: from encounters import _8 elif number == 9: from encounters import _9 elif number == 10: from encounters import _10
All of the imports from encounters are showing as unused, i'm not sure if this is just because they are in an if statement.
there are 10 types of people in this world,
those who understand binary and those who don't.

skype name: J4W3S.23

Reply

RE: unused imports #3
Quick answer: No. And the way you have it is actually better for performance. If you had them all at the very top, importing is quick, but it is not without expense. Here you would be importing individually, instead of all at once. It would be like going to a store and just buying all the ingredients you think you might need, instead of making sure that you only grab what you need... Which would be more expensive?
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: unused imports #4
Quick answer: No. And the way you have it is actually better for performance. If you had them all at the very top, importing is quick, but it is not without expense. Here you would be importing individually, instead of all at once. It would be like going to a store and just buying all the ingredients you think you might need, instead of making sure that you only grab what you need... Which would be more expensive?
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: unused imports #5
oh ok thanks Smile. I didn't think it would effect performance it's i just wanted to make sure because of all the warnings.
there are 10 types of people in this world,
those who understand binary and those who don't.

skype name: J4W3S.23

Reply

RE: unused imports #6
oh ok thanks Smile. I didn't think it would effect performance it's i just wanted to make sure because of all the warnings.
there are 10 types of people in this world,
those who understand binary and those who don't.

skype name: J4W3S.23

Reply

RE: unused imports #7
They can be ignored if you are getting warnings here, because you don't want to use them all I'm assuming.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: unused imports #8
They can be ignored if you are getting warnings here, because you don't want to use them all I'm assuming.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply