Gyroscope and compass. When its better to use one instead of another?
First, to keep in mind: gyroscopes measure how fast you are turning and in what direction.  Compasses measure your orientation to the earth's magnetic pole.

Positive Side of Gyroscopes:
With this in mind, we can see that gyroscopes won't be as sensitive to external magnetic fields as compasses will be.  So, if there's an opportunity for your device to come close to a magnet, a compass may not be what you want.

Also, gyroscopes will work even in space, whereas compasses won't really work.  (Side note: well, actually, the compass will still work, it just might not work in the way you want it to.)

Negative Side of Gyroscopes:
Since a gyroscope measures the how fast you're turning, and not really how far you've turned, you must perform numeric integration (of some form or another) to estimate your actual heading.  This means that some error can be introduced.  Along the same lines, because the sensor value for the current heading is dependent on all those that came before, any significant error in reading from the gyro could throw your calculations off permanently.

Also, a gyroscope is a relative reading, whereas a compass is absolute.  The gyro will tell you how much you've turned since you begun the numeric integration, but it has no way of knowing if it started off pointing north or south.