1. A processor-based method of generating a pipeline for processing a type of network packets, comprising: inputting a first specification that describes the processing of the type of network packets, the specification specifying a plurality of actions for inspecting and modifying at least one of a plurality of fields of the type of network packets; generating a plurality of alternative assignments, each assignment assigning each of the actions to a corresponding stage of a corresponding alternative pipeline having at least one stage; wherein for each assignment and corresponding alternative pipeline, one or more of the actions is assigned to each stage of the pipeline; evaluating at least one quality metric for each of the assignments; selecting a specific one of the assignments in response to the at least one quality metric for the assignments; and generating, by a processor, the corresponding pipeline of the specific assignment, each stage of the corresponding pipeline implementing the inspecting and the modifying of the at least one field of the type of network packets for each action assigned to the stage; wherein the generating the corresponding pipeline includes outputting a second specification that defines for each stage of the corresponding pipeline of the specific assignment, each assigned action.