It really depends on how you implement it.
If you use deionised water (There are also different levels of purity),add sulphuric acid to it(to make it electrically conducting) and use appropriate electrodes you will get very pure hydrogen. You just have to isolate the two electrodes, otherwise you will get a mixture of hydrogen and oxygen, which is definitively not pure and also extremely dangerous.
Just take a look at the Hofmann voltameter on how to do the spacial isolation.
The reaction of hydrides with water generates also pure hydrogen, but you still have to use deionised water and (sometimes pure) hydrides (they need not to be pure if the impurity doesn't liberate a gas in any way in any reaction).
You should take into account that hydrides are very reactive and thus dangerous.
I would prefer (A) because deionised water is cheaper than hydrides ( pure or not) and this way is safer.
The purity of the two means is (if correctly implemented) very high, there is no major difference in purity.
So which way gives the most pure hydrogen depends on some parameters you didn't specify in your question.