The Torah declares in (Exodus 22:17): "A witch you shall not allow to live." The Mekhilta immediately clarifies the scope of this severe commandment. Despite the verse using the feminine form — "a witch" — the prohibition applies equally to both men and women who practice sorcery. The feminine language is not restrictive; it reflects the common but not exclusive association of witchcraft with women in the ancient world.
Rabbi Yishmael then took up the question of method. The verse states that the witch shall not be allowed to live, but it does not specify how the death penalty is to be carried out. The Torah prescribes different forms of capital punishment for different offenses — stoning, burning, strangulation, and the sword — so the question of which method applies here is not trivial.
Rabbi Yishmael resolved the question through a gezeirah shavah — a comparison of identical phrases appearing in two different legal contexts. The verse here says "you shall not allow to live." In (Deuteronomy 20:16), the Torah uses the same phrase — "you shall not allow to live" — in reference to the nations of Canaan during wartime conquest. In that context, the method of execution is clearly by the sword.
Since the same language appears in both passages, Rabbi Yishmael concluded that the same method applies: just as the Canaanite nations were to be killed by the sword, so too a practitioner of witchcraft is to be executed by the sword. The Torah's internal verbal echoes function as a precise legal code, linking one law to another through shared language.