While surfing stack exchange, I have seen many people mentioning speed efficiency in their answers. How is one code faster than the other one which does the same function? 

What makes the code run faster? Less lines? 
Does importing mean loss of performance?
What things should I keep in mind to write performance efficient code?
Why do I need a performance efficient code?

I have also seen people writing 

Loose on speed to gain on beauty? 

Why are beautiful codes slow?
I'll try to give you a concrete answer. Your question is too abroad and involves a lot of things that are not trivial to explain.
How is one code faster than the other one which does the same function? 
For example, you have to find an element in an array. You can look for it in every cell until the end or stop when you have found it. This is the most trivial example I can give you, but I think that is good to a initial idea.
Well, now you would look for "bubble sort" and "quickSort" as examples of algorithm to sort arrays. They do the same job, but the second one much faster.
What makes the code run faster? Less lines? 
Not really, you may be interested in learn something about complexity of algorithms. Search on "Big O Notation", which is a way of describing the asymptotic performance of algorithms.
Does importing mean loss of performance?
It depends on the context. If you need to save resources because of hardware where you will execute your code may yes. In another situations may the differences about performance is very little so you don't have a real problem. 
What things should I keep in mind to write performance efficient code?
You have to learn differents skills about algorithms. (backtracking algorithms, divide and conquer algorithms, dynamic programming algorithms, greedy algorithms, branch and bound algorithms...)
Before that, you will usually use brute force algorithms whick makes your code less efficient.
Why do I need a performance efficient code?
You have a cpu which is not God. If the mayority of the code which is actually run in your computer aren't efficient you would have a problem, everything will be slower. And in some cases impossible to maintain.
Loose on speed to gain on beauty? 
Beautiful code is usually code that is easy to understand.
Often more efficient algorithm are harder to understand, and there are other costs in time to write and maintain the code.
But you can reduce that effect if you get used to write Clean Code.
Your code will be much better, beauty and more efficient in a lot of ways.
It's very important trying to make your code understandable, but if you can't, give some information in comments or documentation about what are you doing in these lines.
I hope this helps you.
Write speed efficient code in python