Python queston?

I have a quick question for you guys. I was reading about python classes, and i was curious if you could explain a little on what they are? I saw examples, but they just look similar to def functions. Also how could they be implimented in blender. An example would be great. Sorry if this is a noob question.
Also do def functions help speed up scripts?
One more question, how is the print framrate and profile pannel used to tell what is what. I have never understood anything else but framerate. a good explanation would be great. What i’m trying to do is speed up my game a little. I dont understand why its so slow, I need to learn how to utilize my memory better. Again sorry for the jumbled up questions

Regarding classes you should read some documentation regarding object orientated programming (OOP). Also ByteOfPython contains some examples with explanations. I suggest to at least read this.

def defines a function ( or member function in terms of classes). They are used to organize the code. Very usefull if repeated code blocks exist. It is also a way to add abstraction to the code that makes it easier to understand.

If you are asking for the module mode of the Python controller, as far as I know yes this is faster than script mode. And it provides the possibility to have multiple functions in one script, rather that one big function.

The profile shows you how much of your processing time (100%) is used by what part of the GE.
This is useful to identify bottlenegs. E.g. it makes no sense to optimize your mesh (see rasterizer) if the bottleneck is a slow script (see logic).

There are some optimization threads already, with a lot of hints what you can do. You might dig through this forum, to find them.

@ Monster.
What do you mean bottlenecking? Also how do you know if you have a slow script?

 I have a script that copys the rotation of a camera in scene 1 and sets it to camera in scene 2.  I use this for a sky box.  Its a small 7line script, but its set to true level triggering "0".  Is this bad?  Could some one tell me what all the things mean in the profile.  I've searched but cant find any real explanations,  ex what is rasterizer? and overhead? Logic?  things like that, and what is it that affects them? Is a low number good or bad?  I hope this isnt annoying anyone.

The big ones:

Rasterizer: Scene rendering, poly count, textures, GLSL effects and so on affect this

Logic: Python and Logic Bricks

Physics: Bullet physics for handling dynamic objects.

If one of those is noticeably larger than the others (it will usually be physics or rasterizer in my experience) than that is the area causing slowdown.

Check what Wikipedia can tell you regarding bottleneck.

If you know about the GameLoop you should know what the BGE is doing all the time. (I know this is not a really good explaination).
The profile shows you how much time it takes for each part of the GameLoop.
Large numbers mean this part needs more time than other parts. If you have performance problem look there first.

If for example the logic takes 60% you should review ALL of your logic. Not just one script.
If rasterizer the rasterizer eats 60% you should check if you could reduce the number of visible faces, or filter, alpha faces etc…

Regarding your script, please read the article regarding sensors.
So you see the script runs with every frame. but if it is a bottleneck I can’t tell without more information.