Skip to content

Commit

Permalink
fix: ulid_now on 32bit (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Mar 13, 2023
1 parent 427b8dd commit c8f7dd7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/ulid_transform/_ulid_impl.pyx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# distutils: language = c++
from libcpp.string cimport string

from time import time

import cython


cdef extern from "ulid_wrapper.h":
string _cpp_ulid()
string _cpp_ulid_at_time(double timestamp)
string _cpp_ulid_to_bytes(string ulid)


def _ulid_now() -> str:
return _cpp_ulid().decode("ascii")
return _cpp_ulid_at_time(time()).decode("ascii")

def _ulid_at_time(time: float) -> str:
return _cpp_ulid_at_time(time).decode("ascii")
def _ulid_at_time(_time: float) -> str:
return _cpp_ulid_at_time(_time).decode("ascii")

def _ulid_to_bytes(ulid_str: str) -> bytes:
if len(ulid_str) != 26:
Expand Down
1 change: 0 additions & 1 deletion src/ulid_transform/ulid_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#ifndef ULID_WRAPPER_H
#define ULID_WRAPPER_H

std::string _cpp_ulid();
std::string _cpp_ulid_at_time(double timestamp);
std::string _cpp_ulid_to_bytes(std::string ulid_string);

Expand Down

0 comments on commit c8f7dd7

Please sign in to comment.