# Optimizing Magma Code

## PowerGroup

If the user is working with enumerated sets of pc-groups that are all subgroups of a common over-group $G$, then the following optimization is strongly recommended. Define the set to have the universe `PowerGroup(G)`. For any subgroup $H$ of $G$, we can find a canonical form for the generators of $H$. This allows us to have a very good hashing function for the subgroups.

### `Example: Power Group Two (ex-952208)`

The following example illustrates the optimization.

```magma
> G := ExtraSpecialGroup( GrpPC, 3, 3 );
> P := PowerGroup(G);
> time s1 := {  P | sub< G | Random(G), Random(G) > : x in { 1..500}  };
Time: 1.140
> time s2 := { Parent(G) | sub< G | Random(G), Random(G) > : x in { 1..500}  };
Time: 9.769

```
