init is not "spawned" (as a child process), but rather
exec'd like this:
# Boot the real thing. exec switch_root /mnt/root /sbin/init
exec replaces the entire process in place. The final init is still the first process (pid 1), even though it was preceded with those in the Initramfs.
/init, which is a Busybox shell script with pid 1,
execs to Busybox
switch_root (so now
switch_root is pid 1); this program does some magic with the mount points so
/mnt/root will be the new
switch_root then again
/sbin/init of your real root filesystem; thereby it makes your real init system the first process with pid 1, which in turn may spawn any number of child processes.
Certainly it could just as well be done with a Python script, if you somehow managed to bake Python into your Initramfs.
However, it does not work on kernels that do not allow script binaries (
CONFIG_BINFMT_SCRIPT=y), or rather in such a case you'd have to start the interpreter directly and make it load your script somehow.