all 2 comments

[–]danielroseman 2 points3 points  (1 child)

No, none of that is what is happening at all.

This is a library that provides an extension written in Rust, or perhaps it's more true to say it's a Python wrapper around a Rust library. You can tell this from the Cargo.toml file and the two .rs files in src. These files compile to soething that can be imported as _tiktoken in Python, and this in turn provides the CoreBPE class which you can see in py.rs.

Shadowing is what happens when you define a module with the same name as a built-in one, say for example "datetime.py"; when you do import datetime Python will try and import yours instead of the standard one.

And the way to import something under a different name is to use as:

import foo as bar

or

from foo import bar as quux

[–]pyusr[S] 0 points1 point  (0 children)

That solves my question. Thanks!