openai / tiktoken

tiktoken is a fast BPE tokeniser for use with OpenAI's models.
MIT License
11.17k stars 751 forks source link

Using tiktoken with async code (python) #210

Closed sometastycake closed 8 months ago

sometastycake commented 8 months ago

How safe is it to use Encoding.encode() (https://github.com/openai/tiktoken/blob/main/tiktoken/core.py#L75) in async code?

In the file I also see the use of ThreadPoolExecutor, but I do not use these methods. But I can’t verify what’s happening in https://github.com/openai/tiktoken/blob/main/tiktoken/core.py#L120, apparently the method is defined in the .so file

hauntsaninja commented 8 months ago

What do you mean by safe? It is blocking code, if that's what you're asking

sometastycake commented 8 months ago

What do you mean by safe?

I meant whether there are blocking I/O operations when calling the Encoding.encode() method

It is blocking code

I/O?

hauntsaninja commented 8 months ago

No I/O