# man > Template::Stash::XS(3pm)

---
type: CommandReference
command: Template::Stash::XS
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference

- `Template::Stash::XS->new(\%vars)` — create new XS stash object
- `Template->new({ STASH => $stash })` — use XS stash with Template Toolkit
- `$Template::Config::STASH = 'Template::Stash::XS'` — set default stash to XS
- Answer 'y' during `perl Makefile.PL` to build and use XS stash by default

## Name

Template::Stash::XS - High-speed variable stash written in C

## Synopsis

perl
use Template;
use Template::Stash::XS;

my $stash = Template::Stash::XS->new(\%vars);
my $tt2   = Template->new({ STASH => $stash });
## Options (Constructor)

- `Template::Stash::XS->new(\%vars)` — create a new XS stash object, initialised with the variable hash reference `\%vars`. This is a drop-in replacement for `Template::Stash->new()`.

## Examples

**Using the XS stash via configuration:**

perl
use Template;
use Template::Stash::XS;

my $stash = Template::Stash::XS->new(\%vars);
my $tt2   = Template->new({ STASH => $stash });
**Setting the default stash globally:**

perl
use Template;
use Template::Config;

$Template::Config::STASH = 'Template::Stash::XS';

my $tt2 = Template->new();
**Enabling at installation time:**

During `perl Makefile.PL`, answer 'y' to:

- Do you want to build the XS Stash module?
- Do you want to use the XS Stash by default?

## Description

The module is an implementation of `Template::Stash` written in C using Perl's XS extension system. It works identically to the pure-Perl `Template::Stash` but runs approximately twice as fast.

The easiest way to use the XS stash is to configure the Template Toolkit to use it by default at installation time. If not elected at installation, the stash can be used by passing a `STASH` option to `Template->new()` or by setting the package variable `$Template::Config::STASH` to `'Template::Stash::XS'` before creating a Template object.

The XS stash is automatically used when `$Template::Config::STASH` is set to that value.

## See Also

- [Template::Stash](https://metacpan.org/pod/Template::Stash) — the pure-Perl stash implementation
- [Template::Config](https://metacpan.org/pod/Template::Config) — configuration module for Template Toolkit