Python CLI: replace -d and -v with -X options

The Python CLI has many options. Most used are short options, there are also fiew long options and a group of -X options for debugging and experimenting. But two short options, -d and -v are almost useless for common Python user. You can expect that they enable “debug” and “verbose” modes, as in many other programs, and they do, but… -d only debugs the Python parser. The output is so detailed, that it can only be intertested for few people in the world whou develop the Python parser, and perhaps it is too verbose even for them. -v only logs imports and cleanups at Python shutdown. It can be useful, but it is similar to -X importtime which may provide more useful output. I think that if these options would be added today, they would be added as -X options.

I propose to add new -X options as aliases to -d and -v. Few years later we could deprecate -d and -v options, and finally remove them. Then we could reuse these names for something more useful, for example enable line tracing or debugging. Even if we have no plans to remove them, we could remove them from the first page of the help.



That -d for the parser… does not sound like something users could ever find useful? I suspect we could remove that in favor of a -X alternative spelling without compatibility concerns. Proper process though is to do as you suggest and provide and promote an alternative from our help text for a while first. I doubt anyone would object.

For -v, it isn’t something anyone should depend on the specific verbose output of, but is something users are familiar with typing when they want to see import details. Meaning we could also opt to just change its behavior to perhaps be an alias for something else similarly verbose but deemed more useful, such as -X importtime.


Funny enough, just the other day I ran into a situation helping a user on here where the output of -v was potentially useful (an import path/shadowing issue for a module), though that was the first time I’d used it for a long while, and was surprised to be reminded that -v only shows those two very specific forms of verbose output, as opposed to something more generally relevant.

As such, ISTM it makes sense to at least introduce an -X option for it (or perhaps even separate options for the two distinct types of output), as part of a future path toward removing, replacing or at least de-empahsizing these options and making their behavior more clear. I’m not sure -X importtime would necessarily make sense as a replacement, though, as it would be equally if not more surprising to have -v trigger that specific behavior, and it serves a somewhat different purpose.


That sounds reasonable to me. Even -v isn’t very usable in the cases where you’d want something like that, i.e. when wanting to diagnose the import tree of heavy libraries to find pain points.

1 Like

In PyConfig, I chose the name “parser_debug” rather than “debug” for -d option.

For -v verbose option, it would be nice to have a way to write such debug logs into a file. Like: -X debug_import:import.log. Currently, it’s barely usable.

1 Like