mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 20:10:17 +00:00
rename some config keys
This commit is contained in:
parent
512ca74e35
commit
2898fbd5cb
@ -45,19 +45,17 @@
|
|||||||
// (not recommended to change this / it should be less than 200)
|
// (not recommended to change this / it should be less than 200)
|
||||||
#define PK_MAX_CO_VARNAMES 32
|
#define PK_MAX_CO_VARNAMES 32
|
||||||
|
|
||||||
namespace pkpy{
|
// Hash table load factor (smaller ones mean less collision but more memory)
|
||||||
// Hash table load factor (smaller ones mean less collision but more memory)
|
// For class instance
|
||||||
// For class instance
|
#define PK_INST_ATTR_LOAD_FACTOR 0.67
|
||||||
inline const float kInstAttrLoadFactor = 0.67f;
|
// For class itself
|
||||||
// For class itself
|
#define PK_TYPE_ATTR_LOAD_FACTOR 0.5
|
||||||
inline const float kTypeAttrLoadFactor = 0.5f;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
inline const char kPlatformSep = '\\';
|
#define PK_PLATFORM_SEP '\\'
|
||||||
#else
|
#else
|
||||||
inline const char kPlatformSep = '/';
|
#define PK_PLATFORM_SEP '/'
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable:4267)
|
#pragma warning (disable:4267)
|
||||||
|
@ -57,19 +57,17 @@
|
|||||||
// (not recommended to change this / it should be less than 200)
|
// (not recommended to change this / it should be less than 200)
|
||||||
#define PK_MAX_CO_VARNAMES 32
|
#define PK_MAX_CO_VARNAMES 32
|
||||||
|
|
||||||
namespace pkpy{
|
// Hash table load factor (smaller ones mean less collision but more memory)
|
||||||
// Hash table load factor (smaller ones mean less collision but more memory)
|
// For class instance
|
||||||
// For class instance
|
#define PK_INST_ATTR_LOAD_FACTOR 0.67
|
||||||
inline const float kInstAttrLoadFactor = 0.67f;
|
// For class itself
|
||||||
// For class itself
|
#define PK_TYPE_ATTR_LOAD_FACTOR 0.5
|
||||||
inline const float kTypeAttrLoadFactor = 0.5f;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
inline const char kPlatformSep = '\\';
|
#define PK_PLATFORM_SEP '\\'
|
||||||
#else
|
#else
|
||||||
inline const char kPlatformSep = '/';
|
#define PK_PLATFORM_SEP '/'
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning (disable:4267)
|
#pragma warning (disable:4267)
|
||||||
|
@ -119,7 +119,7 @@ while(!_items[i].first.empty()) { \
|
|||||||
|
|
||||||
#define HASH_PROBE_0 HASH_PROBE_1
|
#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);
|
_set_capacity_and_alloc_items(kInitialCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ template<>
|
|||||||
struct Py_<Type> final: PyObject {
|
struct Py_<Type> final: PyObject {
|
||||||
Type _value;
|
Type _value;
|
||||||
Py_(Type type, Type val): PyObject(type), _value(val) {
|
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 _obj_gc_mark() override {}
|
||||||
void* _value_ptr() override { return &_value; }
|
void* _value_ptr() override { return &_value; }
|
||||||
@ -379,7 +379,7 @@ struct Py_<Type> final: PyObject {
|
|||||||
template<>
|
template<>
|
||||||
struct Py_<DummyModule> final: PyObject {
|
struct Py_<DummyModule> final: PyObject {
|
||||||
Py_(Type type): PyObject(type) {
|
Py_(Type type): PyObject(type) {
|
||||||
_enable_instance_dict(kTypeAttrLoadFactor);
|
_enable_instance_dict(PK_TYPE_ATTR_LOAD_FACTOR);
|
||||||
}
|
}
|
||||||
void _obj_gc_mark() override {}
|
void _obj_gc_mark() override {}
|
||||||
void* _value_ptr() override { return nullptr; }
|
void* _value_ptr() override { return nullptr; }
|
||||||
|
@ -329,7 +329,7 @@ namespace pkpy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try import
|
// try import
|
||||||
Str filename = path.replace('.', kPlatformSep) + ".py";
|
Str filename = path.replace('.', PK_PLATFORM_SEP) + ".py";
|
||||||
Str source;
|
Str source;
|
||||||
bool is_init = false;
|
bool is_init = false;
|
||||||
auto it = _lazy_modules.find(name);
|
auto it = _lazy_modules.find(name);
|
||||||
@ -337,7 +337,7 @@ namespace pkpy{
|
|||||||
int out_size;
|
int out_size;
|
||||||
unsigned char* out = _import_handler(filename.data, filename.size, &out_size);
|
unsigned char* out = _import_handler(filename.data, filename.size, &out_size);
|
||||||
if(out == nullptr){
|
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;
|
is_init = true;
|
||||||
out = _import_handler(filename.data, filename.size, &out_size);
|
out = _import_handler(filename.data, filename.size, &out_size);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user