# Re: Equivalent of Python zfill?

**URL:** <https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95338>\
**Category:** Ruby\
**Created:** [May 29, 2006, 12:25pm UTC](https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95338 "2006-05-29T12:25:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 29, 2006, 12:25pm UTC](https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95338/1 "2006-05-29T12:25:24Z")

</div>

fr Peter:

# But if “0”\*7 is the ‘normal’ way of doing this, it’s OK with me.

in ruby in general, the shorter and simpler, the faster.

kind regards -botp

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [May 29, 2006, 12:34pm UTC](https://www.ruby-forum.com/t/re-equivalent-of-python-zfill/95338/2 "2006-05-29T12:34:31Z")

</div>

On 5/29/06, PeÃ±a, Botp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> fr Peter:
> 
> # But if “0”\*7 is the ‘normal’ way of doing this, it’s OK with me.
> 
> in ruby in general, the shorter and simpler, the faster.
> 
> kind regards -botp

it might be worth profiling something like this:

# at start of code

lotsazeros = ‘0’ \* 1000

# various places in code

seven\_zeros = lotsazeros[0…6]  
three\_thousand\_and\_ten\_zeros = lotsazeros \* 3 + ‘0’ \* 10

no idea how this performs, just thought it’d be worth trying…

;D
