Create pfa.py

basic optimization