Pyth is in ongoing development, meaning that new features are being added all the time.

I want to make Pyth a better langauge, so I'd like to know what features people are looking for.

This is the place the post ideas you have for making Pyth better.

In your answer, please state:

  • What you'd like to see changed/added.

  • An example usage of the change.

I'll comment if I'm planning to implement the suggestion.

Please check if the idea you want to suggest has already been suggested. Upvote ideas you'd like implemented.

Implemented suggestions:

This was on topic as per this meta question when I posted the question, it is no longer clear.

  • 1
    \$\begingroup\$ Why is this a community wiki? \$\endgroup\$
    – Geobits
    Oct 7, 2015 at 18:19
  • 4
    \$\begingroup\$ It's more of a discussion and collection of suggestions. Nobody should gain or lose rep for suggesting a Pyth feature. Also, implemented suggestions should probably be deleted. This related question is also community wiki. \$\endgroup\$
    – Dennis
    Oct 7, 2015 at 18:25
  • 9
    \$\begingroup\$ I'm not sure how I feel about questions like this. I can see that it sort of makes sense here, because PPCG probably covers most (if not all) of Pyth's user base, but I'm not sure we should use it as an issue tracker. I have added an answer to the meta post. \$\endgroup\$ Oct 8, 2015 at 7:12
  • \$\begingroup\$ Shouldn't this been meta? Seriously guys \$\endgroup\$
    – Alec Teal
    Oct 9, 2015 at 7:02
  • 2
    \$\begingroup\$ @AlecTeal "Meta Programming Puzzles & Code Golf Stack Exchange is the part of the site where users discuss the workings and policies of Code Golf Stack Exchange rather than discussing programming puzzles or code golf itself." Meta is specifically about this community. It really doesn't belong on meta. Whether it belongs here or not on PPCG at all is currently being discussed in the meta post I linked. \$\endgroup\$ Oct 9, 2015 at 8:29

9 Answers 9


Nested loops

If you want to nest for loops, you currently have to waste a byte for using F<var><seq> inside a V<seq> or vice versa. I'd love to have the same thing as with lambdas, where the variable used for the loop would change when nesting loops.

  • \$\begingroup\$ This might even be extensible to other things like L, which could redefine, say, C the second time it were called. \$\endgroup\$ Oct 7, 2015 at 20:33


Pyth equivalent of turtle graphics, as per import turtle.


Easier Module Importing

So far, every time I have used $ it has been something like:

$from <module> import <function> as <pyth-function-with-same-arity>$
for example:
$from unicodedata import name as neg$

There could be a new function that summarized this for example .$:

.$"unicodedata name neg"

Or using the newer syntax like _M which may not be easy/possible to do:

_$unicodedata name$

In addition, one function with each arity could be given a single letter macro name so that these calls could be shorter (except for the _$ option).



This caused trouble here, and @mbomb007 suggested to put it as an improvement to Pyth. Basically, right now, in order to sleep for the given number of seconds, I need to do something like:


Which is annoying and long as heck.

  • \$\begingroup\$ You can simulate the sleeping behaviour with the date-function. f>.d1Q0 for instance sleeps Q seconds. \$\endgroup\$
    – Jakube
    Oct 9, 2015 at 18:43
  • \$\begingroup\$ @Jakube That doesn't always work. According to the docs, on Unix, it returns how long the program has been running for. Which is bad when the user is entering input. \$\endgroup\$ Oct 9, 2015 at 18:45
  • \$\begingroup\$ How about this one than: J.d0f>-.d0JQ0. It's quite long though... I agree, a sleep function would be nice. \$\endgroup\$
    – Jakube
    Oct 9, 2015 at 18:48

More lambdas

This is really FryAmTheEggman's idea, but I'm posting it to get it out there.

Sometimes I find that using two different one-argument lambdas would shorten the code, while having to use a two-argument lambda for one wouldn't.

It would be nice to have L, M and friends redefine a different function every time used; for example, this code:


could compile to:

def subsets(b):
 return times(b,2)
def read_file(b):
 return times(b,3)

The exact choice of functions could be changed, of course.


Improved multi-dimensional arrays

Using multi-dimensional arrays is rather hard to do currently. For example, the C code A[B][C][D] would translate to @@@ABCD in Pyth. Something like @A[BCD) would be much nicer (albeit not any shorter here). The same also goes for X; A[B][C][D] = E is currently X@@ABCDE, when it could be XA[BCD)E.


Some minor ideas

  • Absolute difference, i.e. abs(val1 - val2). Currently it's .a-<val1><val2>.
  • min/max for values. Currently it's hS,<val1><val2>/eS,<val1><val2> or the same thing with more values. (hS<seq>/eS<seq> for sequences is short enough.)

Not a Pyth feature, but nevertheless...

Modularize the Pyth code

This only affects Pyth under the hood. Some parts of the Pyth implementation are quite messy. Lots of global variables and other hacky things.

I really got frustrated a few days ago, when I tried using a few functions of the Pyth implementation (like executing a string of Pyth commands) from another Python script.

Something like the following would be nice:

from pyth import execute_pyth
print(execute_pyth(code='sQ', input='[1, 2, 3]'))

Well, I guess this is just a help call for Pyth5.


Unique elements

Pyth currently has no short way of getting unique elements of a sequence. You can test if it's unique, but you can't get the items that are actually unique. Currently, the shortest way is:


6 bytes! Compare that to K, where getting the unique elements is a one-byte operation: =x.

Maybe .} would work here?

  • \$\begingroup\$ What use cases (other than tat one challenge) are you thinking of? \$\endgroup\$
    – isaacg
    Oct 15, 2015 at 20:57
  • \$\begingroup\$ @isaacg I can't quite recall, but I've had to try and get the unique elements of a list before and had to use something else (which was always longer). \$\endgroup\$ Oct 15, 2015 at 20:58
  • \$\begingroup\$ I'm not a Pyth programmer, but I run into this all the time in GolfScript/CJam: .& resp. _& appears in a lot of answers. It's very useful. \$\endgroup\$
    – Lynn
    Oct 15, 2015 at 21:06
  • 1
    \$\begingroup\$ How is this different from {Q? \$\endgroup\$
    – isaacg
    Oct 15, 2015 at 21:43
  • 1
    \$\begingroup\$ @isaacg It's sorted \$\endgroup\$
    – Ypnypn
    Oct 15, 2015 at 21:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.