Eleven Years of Service
Posts: 56
Threads: 9
Points: 0NSP
unused imports 03-31-2013, 01:23 AM
#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
•
Eleven Years of Service
Posts: 56
Threads: 9
Points: 0NSP
unused imports 03-31-2013, 01:23 AM
#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
•
Twelve Years of Service
Posts: 1,474
Threads: 91
Points: 2NSP
RE: unused imports 03-31-2013, 11:58 AM
#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?
•
Twelve Years of Service
Posts: 1,474
Threads: 91
Points: 2NSP
RE: unused imports 03-31-2013, 11:58 AM
#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?
•
Eleven Years of Service
Posts: 56
Threads: 9
Points: 0NSP
RE: unused imports 03-31-2013, 12:38 PM
#5
oh ok thanks

. 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
•
Eleven Years of Service
Posts: 56
Threads: 9
Points: 0NSP
RE: unused imports 03-31-2013, 12:38 PM
#6
oh ok thanks

. 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
•
Twelve Years of Service
Posts: 1,474
Threads: 91
Points: 2NSP
RE: unused imports 03-31-2013, 01:06 PM
#7
They can be ignored if you are getting warnings here, because you don't want to use them all I'm assuming.
•
Twelve Years of Service
Posts: 1,474
Threads: 91
Points: 2NSP
RE: unused imports 03-31-2013, 01:06 PM
#8
They can be ignored if you are getting warnings here, because you don't want to use them all I'm assuming.
•