rename some config keys

This commit is contained in:
blueloveTH 2023-12-30 15:04:17 +08:00
parent 512ca74e35
commit 2898fbd5cb
5 changed files with 25 additions and 29 deletions

View File

@ -45,19 +45,17 @@
// (not recommended to change this / it should be less than 200)
#define PK_MAX_CO_VARNAMES 32
namespace pkpy{
// Hash table load factor (smaller ones mean less collision but more memory)
// For class instance
inline const float kInstAttrLoadFactor = 0.67f;
// For class itself
inline const float kTypeAttrLoadFactor = 0.5f;
// Hash table load factor (smaller ones mean less collision but more memory)
// For class instance
#define PK_INST_ATTR_LOAD_FACTOR 0.67
// For class itself
#define PK_TYPE_ATTR_LOAD_FACTOR 0.5
#ifdef _WIN32
inline const char kPlatformSep = '\\';
#else
inline const char kPlatformSep = '/';
#endif
}
#ifdef _WIN32
#define PK_PLATFORM_SEP '\\'
#else
#define PK_PLATFORM_SEP '/'
#endif
#ifdef _MSC_VER
#pragma warning (disable:4267)

View File

@ -57,19 +57,17 @@
// (not recommended to change this / it should be less than 200)
#define PK_MAX_CO_VARNAMES 32
namespace pkpy{
// Hash table load factor (smaller ones mean less collision but more memory)
// For class instance
inline const float kInstAttrLoadFactor = 0.67f;
// For class itself
inline const float kTypeAttrLoadFactor = 0.5f;
// Hash table load factor (smaller ones mean less collision but more memory)
// For class instance
#define PK_INST_ATTR_LOAD_FACTOR 0.67
// For class itself
#define PK_TYPE_ATTR_LOAD_FACTOR 0.5
#ifdef _WIN32
inline const char kPlatformSep = '\\';
#else
inline const char kPlatformSep = '/';
#endif
}
#ifdef _WIN32
#define PK_PLATFORM_SEP '\\'
#else
#define PK_PLATFORM_SEP '/'
#endif
#ifdef _MSC_VER
#pragma warning (disable:4267)

View File

@ -119,7 +119,7 @@ while(!_items[i].first.empty()) { \
#define HASH_PROBE_0 HASH_PROBE_1
LargeNameDict(float load_factor=kInstAttrLoadFactor): _is_small(false), _load_factor(load_factor), _size(0) {
LargeNameDict(float load_factor=PK_INST_ATTR_LOAD_FACTOR): _is_small(false), _load_factor(load_factor), _size(0) {
_set_capacity_and_alloc_items(kInitialCapacity);
}

View File

@ -370,7 +370,7 @@ template<>
struct Py_<Type> final: PyObject {
Type _value;
Py_(Type type, Type val): PyObject(type), _value(val) {
_enable_instance_dict(kTypeAttrLoadFactor);
_enable_instance_dict(PK_TYPE_ATTR_LOAD_FACTOR);
}
void _obj_gc_mark() override {}
void* _value_ptr() override { return &_value; }
@ -379,7 +379,7 @@ struct Py_<Type> final: PyObject {
template<>
struct Py_<DummyModule> final: PyObject {
Py_(Type type): PyObject(type) {
_enable_instance_dict(kTypeAttrLoadFactor);
_enable_instance_dict(PK_TYPE_ATTR_LOAD_FACTOR);
}
void _obj_gc_mark() override {}
void* _value_ptr() override { return nullptr; }

View File

@ -329,7 +329,7 @@ namespace pkpy{
}
// try import
Str filename = path.replace('.', kPlatformSep) + ".py";
Str filename = path.replace('.', PK_PLATFORM_SEP) + ".py";
Str source;
bool is_init = false;
auto it = _lazy_modules.find(name);
@ -337,7 +337,7 @@ namespace pkpy{
int out_size;
unsigned char* out = _import_handler(filename.data, filename.size, &out_size);
if(out == nullptr){
filename = path.replace('.', kPlatformSep).str() + kPlatformSep + "__init__.py";
filename = path.replace('.', PK_PLATFORM_SEP).str() + PK_PLATFORM_SEP + "__init__.py";
is_init = true;
out = _import_handler(filename.data, filename.size, &out_size);
}