Swap partition is set and forget. Can be detected by label automatically, never fails.
Swap file means fallocating, setting extended attributes (like `nocow`), finding file offset and writing it to kernel params, and other gotchas, like btrfs not allowing snapshotting a subvolume with an active swap file.
Technically it's preferable, won't argue with that.