RAM compatibility between MacBook Pros
Here are the specs for the mid 2009 13" MacBook Pro:


Double Data Rate Small Outline Dual Inline Memory Module (DDR3) format
30mm (1.18 inch)
2 GB or 4 GB
204-pin
PC3-8500 DDR3 1066 MHz type RAM


And the mid 2012 13" MacBook Pro:


Double Data Rate Small Outline Dual Inline Memory Module (DDR3) format
67.6mm x 30mm (1.18 inch)
2 GB or 4 GB
204-pin
PC3-12800 DDR3 1600 MHz type RAM


It'll work, it's slightly faster than the RAM it came with.